Skip to content

Commit

Permalink
feat(vue-cli): Choosing to save as a preset tells you where it is sav…
Browse files Browse the repository at this point in the history
…ed (#5212)

close #5197

Co-authored-by: Jair Reina <Jair.Reina@digitaslbi.com>
  • Loading branch information
jaireina and Jair Reina committed Mar 21, 2020
1 parent c8e6450 commit e5449ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/@vue/cli/lib/Creator.js
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
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 })
}

0 comments on commit e5449ad

Please sign in to comment.