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

Commit

Permalink
fix: clear cached answers when generator is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Nov 6, 2018
1 parent 7de5cf5 commit 86b54fc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const isLocalPath = require('./utils/isLocalPath')
const SAOError = require('./SAOError')
const parseGenerator = require('./parseGenerator')
const updateCheck = require('./updateCheck')
const store = require('./store')

class SAO {
/**
Expand Down Expand Up @@ -64,11 +65,20 @@ class SAO {
? loaded.data
: require(path.join(__dirname, 'saofile.fallback.js'))

if (!parent && this.opts.updateCheck) {
updateCheck({
generator,
checkGenerator: config.updateCheck !== false && generator.type === 'npm'
})
// Only run following code for root generator
if (!parent) {
if (this.opts.updateCheck) {
updateCheck({
generator,
checkGenerator:
config.updateCheck !== false && generator.type === 'npm'
})
}
}

// When updated, the cached answers should be cleared too
if (this.opts.update && generator.hash) {
store.delete(`answers.${generator.hash}`)
}

if (generator.subGenerator) {
Expand Down Expand Up @@ -205,7 +215,7 @@ async function ensurePackage(generator, update) {
'utf8'
)
logger.debug('Installing generator at', installPath)
await require('./installPackages')({
await installPackages({
cwd: installPath,
packages: [`${generator.name}@${generator.version || 'latest'}`]
})
Expand Down

0 comments on commit 86b54fc

Please sign in to comment.