Skip to content

Commit a1097f2

Browse files
haoqunjiangyyx990803
authored andcommitted
fix(create): clear tmpdir before cloning remote preset, fix #1878 (#1880)
1 parent d26cb86 commit a1097f2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = function fetchRemotePreset (name, clone) {
1+
const fs = require('fs-extra')
2+
3+
module.exports = async function fetchRemotePreset (name, clone) {
24
// github shorthand fastpath
35
if (!clone && /^[\w_-]+\/[\w_-]+$/.test(name)) {
46
const { request } = require('@vue/cli-shared-utils')
@@ -12,6 +14,12 @@ module.exports = function fetchRemotePreset (name, clone) {
1214
const download = require('download-git-repo')
1315
const tmpdir = path.join(os.tmpdir(), 'vue-cli')
1416

17+
// clone will fail if tmpdir already exists
18+
// https://github.com/flipxfx/download-git-repo/issues/41
19+
if (clone) {
20+
await fs.remove(tmpdir)
21+
}
22+
1523
return new Promise((resolve, reject) => {
1624
download(name, tmpdir, { clone }, err => {
1725
if (err) return reject(err)

0 commit comments

Comments
 (0)