fix(create): clear tmpdir before cloning remote preset, fix #1878 (#1880)

This commit is contained in:
Haoqun Jiang
2018-07-18 02:40:03 +08:00
committed by Evan You
parent d26cb864b4
commit a1097f27e2
@@ -1,4 +1,6 @@
module.exports = function fetchRemotePreset (name, clone) {
const fs = require('fs-extra')
module.exports = async function fetchRemotePreset (name, clone) {
// github shorthand fastpath
if (!clone && /^[\w_-]+\/[\w_-]+$/.test(name)) {
const { request } = require('@vue/cli-shared-utils')
@@ -12,6 +14,12 @@ module.exports = function fetchRemotePreset (name, clone) {
const download = require('download-git-repo')
const tmpdir = path.join(os.tmpdir(), 'vue-cli')
// clone will fail if tmpdir already exists
// https://github.com/flipxfx/download-git-repo/issues/41
if (clone) {
await fs.remove(tmpdir)
}
return new Promise((resolve, reject) => {
download(name, tmpdir, { clone }, err => {
if (err) return reject(err)