Skip to content

Commit e5449ad

Browse files
jaireinaJair Reina
and
Jair Reina
authored
feat(vue-cli): Choosing to save as a preset tells you where it is saved (vuejs#5212)
close vuejs#5197 Co-authored-by: Jair Reina <[email protected]>
1 parent c8e6450 commit e5449ad

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/@vue/cli/lib/Creator.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const {
2121
saveOptions,
2222
loadOptions,
2323
savePreset,
24-
validatePreset
24+
validatePreset,
25+
rcPath
2526
} = require('./options')
2627

2728
const {
@@ -309,8 +310,9 @@ module.exports = class Creator extends EventEmitter {
309310
validatePreset(preset)
310311

311312
// save preset
312-
if (answers.save && answers.saveName) {
313-
savePreset(answers.saveName, preset)
313+
if (answers.save && answers.saveName && savePreset(answers.saveName, preset)) {
314+
log()
315+
log(`🎉 Preset ${chalk.yellow(answers.saveName)} saved in ${chalk.yellow(rcPath)}`)
314316
}
315317

316318
debug('vue-cli:preset')(preset)

packages/@vue/cli/lib/options.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ exports.saveOptions = toSave => {
9494
cachedOptions = options
9595
try {
9696
fs.writeFileSync(rcPath, JSON.stringify(options, null, 2))
97+
return true
9798
} catch (e) {
9899
error(
99100
`Error saving preferences: ` +
@@ -106,5 +107,5 @@ exports.saveOptions = toSave => {
106107
exports.savePreset = (name, preset) => {
107108
const presets = cloneDeep(exports.loadOptions().presets || {})
108109
presets[name] = preset
109-
exports.saveOptions({ presets })
110+
return exports.saveOptions({ presets })
110111
}

0 commit comments

Comments
 (0)