Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
fix: don't show update notifier for generators after being updated
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 7, 2018
1 parent 9a7ede4 commit 266bd06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class SAO {
updateCheck({
generator,
checkGenerator:
config.updateCheck !== false && generator.type === 'npm'
config.updateCheck !== false && generator.type === 'npm',
// Don't show the notifier after updated the generator
// Since the notifier is for the older version
showNotifier: !this.opts.update
})
}
// Keep the generator info
Expand Down
9 changes: 5 additions & 4 deletions lib/updateCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const chalk = require('chalk')
const yarnGlobal = require('yarn-global')
const logger = require('./logger')

module.exports = ({ generator, checkGenerator }) => {
module.exports = ({ generator, checkGenerator, showNotifier }) => {
performSelfUpdateCheck()
if (checkGenerator) {
performGeneratorUpdateCheck(generator)
performGeneratorUpdateCheck(generator, showNotifier)
}
}

Expand All @@ -33,18 +33,19 @@ function performSelfUpdateCheck() {
}
}

function performGeneratorUpdateCheck(generator) {
function performGeneratorUpdateCheck(generator, showNotifier) {
const pkg = require(path.join(generator.path, 'package.json'))

const notifier = updateNotifier({ pkg })

if (notifier.update) {
if (notifier.update && showNotifier) {
process.on('exit', () => {
logger.warn(
`The generator you were running is out of date. The latest version is "${
notifier.update.latest
}", while you're on "${notifier.update.current}".`
)

logger.tip(
`To run the generator with an updated version, run the following command:\n${chalk.dim(
'$ sao ' + process.argv.slice(2).join(' ') + ' --update'
Expand Down

0 comments on commit 266bd06

Please sign in to comment.