diff --git a/lib/index.js b/lib/index.js index 4248560..a696749 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,7 +13,6 @@ const isLocalPath = require('./utils/isLocalPath') const SAOError = require('./SAOError') const parseGenerator = require('./parseGenerator') const updateCheck = require('./updateCheck') -const store = require('./store') class SAO { /** @@ -76,11 +75,6 @@ class SAO { } } - // When updated, the cached answers should be cleared too - if (this.opts.update && generator.hash) { - store.delete(`answers.${generator.hash}`) - } - if (generator.subGenerator) { const subGenerator = config.generators && diff --git a/lib/runPrompts.js b/lib/runPrompts.js index ff55d86..945242b 100644 --- a/lib/runPrompts.js +++ b/lib/runPrompts.js @@ -1,4 +1,5 @@ const inquirer = require('inquirer') +const resolveFrom = require('resolve-from') const logger = require('./logger') const store = require('./store') const renderTemplate = require('./utils/renderTemplate') @@ -13,7 +14,11 @@ module.exports = async (config, context) => { ? await config.prompts.call(context, context) : config.prompts - const STORED_ANSWERS_ID = `answers.${context.generator.hash}` + const pkgPath = resolveFrom.silent(context.generator.path, 'package.json') + const pkgVersion = pkgPath ? require(pkgPath).version : '' + const STORED_ANSWERS_ID = `answers.${context.generator.hash + + '__npm__' + + pkgVersion}` const storedAnswers = store.get(STORED_ANSWERS_ID) || {} const { mock, yes } = context.sao.opts