Skip to content

Commit f7b95ac

Browse files
haoqunjiangpksunkara
authored andcommitted
fix: should download to different directories for different pre… (#4922)
fixes #4778
1 parent 02f2436 commit f7b95ac

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/@vue/cli/lib/util/loadRemotePreset.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
const fs = require('fs-extra')
22
const loadPresetFromDir = require('./loadPresetFromDir')
33

4-
module.exports = async function fetchRemotePreset (name, clone) {
4+
module.exports = async function loadRemotePreset (repository, clone) {
55
const os = require('os')
66
const path = require('path')
77
const download = require('download-git-repo')
8-
const tmpdir = path.join(os.tmpdir(), 'vue-cli')
8+
9+
const presetName = repository
10+
.replace(/((?:.git)?#.*)/, '')
11+
.split('/')
12+
.slice(-1)[0]
13+
// for direct urls, it's hard to get the correct project name,
14+
// but we need to at least make sure no special characters remaining
15+
.replace(/[:#]/g, '')
16+
17+
const tmpdir = path.join(os.tmpdir(), 'vue-cli-presets', presetName)
918

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

1625
await new Promise((resolve, reject) => {
17-
download(name, tmpdir, { clone }, err => {
26+
download(repository, tmpdir, { clone }, err => {
1827
if (err) return reject(err)
1928
resolve()
2029
})

0 commit comments

Comments
 (0)