Skip to content

If no offline specified. We should remove the tmp dir if it is existed. #390

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/vue-init
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var generate = require('../lib/generate')
var checkVersion = require('../lib/check-version')
var warnings = require('../lib/warnings')
var { isLocalPath, getTemplatePath } = require('../lib/local-path')
var rm = require('rimraf').sync

/**
* Usage.
Expand Down Expand Up @@ -62,9 +63,11 @@ var to = path.resolve(rawName || '.')
var clone = program.clone || false

var tmp = path.join(home, '.vue-templates', template.replace(/\//g, '-'))
if (program.offline) {
if (program.offline && exists(tmp)) {
console.log(`> Use cached template at ${chalk.yellow(tildify(tmp))}`)
template = tmp
} else {
rm(tmp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it should overwrite existing file after successful download.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's best. Needs another dir to cache the downloads. Otherwise the git will throw an error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native /tmp (😝 And whatever alternative for windows) directory can be used for that.

}

/**
Expand Down