Skip to content

Commit

Permalink
fix: should download to different directories for different pre… (#4922)
Browse files Browse the repository at this point in the history
fixes #4778
  • Loading branch information
sodatea authored and pksunkara committed Dec 12, 2019
1 parent 02f2436 commit f7b95ac
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/@vue/cli/lib/util/loadRemotePreset.js
@@ -1,11 +1,20 @@
const fs = require('fs-extra')
const loadPresetFromDir = require('./loadPresetFromDir')

module.exports = async function fetchRemotePreset (name, clone) {
module.exports = async function loadRemotePreset (repository, clone) {
const os = require('os')
const path = require('path')
const download = require('download-git-repo')
const tmpdir = path.join(os.tmpdir(), 'vue-cli')

const presetName = repository
.replace(/((?:.git)?#.*)/, '')
.split('/')
.slice(-1)[0]
// for direct urls, it's hard to get the correct project name,
// but we need to at least make sure no special characters remaining
.replace(/[:#]/g, '')

const tmpdir = path.join(os.tmpdir(), 'vue-cli-presets', presetName)

// clone will fail if tmpdir already exists
// https://github.com/flipxfx/download-git-repo/issues/41
Expand All @@ -14,7 +23,7 @@ module.exports = async function fetchRemotePreset (name, clone) {
}

await new Promise((resolve, reject) => {
download(name, tmpdir, { clone }, err => {
download(repository, tmpdir, { clone }, err => {
if (err) return reject(err)
resolve()
})
Expand Down

0 comments on commit f7b95ac

Please sign in to comment.