Skip to content

Commit

Permalink
fix(create): clear tmpdir before cloning remote preset, fix #1878 (#1880
Browse files Browse the repository at this point in the history
)
  • Loading branch information
haoqunjiang authored and yyx990803 committed Jul 17, 2018
1 parent d26cb86 commit a1097f2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/@vue/cli/lib/util/fetchRemotePreset.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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)
Expand Down

0 comments on commit a1097f2

Please sign in to comment.