Skip to content

Commit 22ccbfb

Browse files
committed
feat(clone): try clone if cannot pull repository
1 parent 49d1a35 commit 22ccbfb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/getTemplate/clone.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ const repositoryExisted = async (repository, storage) => {
1515
module.exports = async (repository, storage) => {
1616
if (await repositoryExisted(repository, storage)) {
1717
log.info(`pull template from ${repository}...`)
18-
await git(storage).pull()
18+
try {
19+
await git(storage).pull()
20+
} catch (e) {
21+
log.warn(`cannot pull template. try clone from ${repository}...`)
22+
await fs.remove(storage)
23+
await git().clone(repository, storage)
24+
}
1925
} else {
2026
log.info(`clone template from ${repository}...`)
2127
await fs.remove(storage)

src/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ exports.error = (type, string, ...arg) =>
99
exports.info = string =>
1010
console.log(chalk.green(`[mili info] ${string}`))
1111

12-
exports.warn = (type, string, ...arg) =>
12+
exports.warn = (string, ...arg) =>
1313
console.log(chalk.yellow(`[mili warn] ${string}`), ...arg)
1414

0 commit comments

Comments
 (0)