Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should download to different directories for different presets #4922

Merged
merged 1 commit into from Dec 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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