Skip to content

feat(vue-cli): Choosing to save as a preset tells you where it is saved #5212

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

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const {
saveOptions,
loadOptions,
savePreset,
validatePreset
validatePreset,
rcPath
} = require('./options')

const {
Expand Down Expand Up @@ -309,8 +310,9 @@ module.exports = class Creator extends EventEmitter {
validatePreset(preset)

// save preset
if (answers.save && answers.saveName) {
savePreset(answers.saveName, preset)
if (answers.save && answers.saveName && savePreset(answers.saveName, preset)) {
log()
log(`🎉 Preset ${chalk.yellow(answers.saveName)} saved in ${chalk.yellow(rcPath)}`)
}

debug('vue-cli:preset')(preset)
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ exports.saveOptions = toSave => {
cachedOptions = options
try {
fs.writeFileSync(rcPath, JSON.stringify(options, null, 2))
return true
} catch (e) {
error(
`Error saving preferences: ` +
Expand All @@ -106,5 +107,5 @@ exports.saveOptions = toSave => {
exports.savePreset = (name, preset) => {
const presets = cloneDeep(exports.loadOptions().presets || {})
presets[name] = preset
exports.saveOptions({ presets })
return exports.saveOptions({ presets })
}