diff --git a/lib/plugins/interactiveCli/initializeService.js b/lib/plugins/interactiveCli/initializeService.js index ebc8a0ac188..879df679d2e 100644 --- a/lib/plugins/interactiveCli/initializeService.js +++ b/lib/plugins/interactiveCli/initializeService.js @@ -80,7 +80,7 @@ module.exports = { process.chdir(projectDir); serverless.config.servicePath = projectDir; - getServerlessConfigFile.cache.delete(serverless); + getServerlessConfigFile.delete(serverless); getServerlessConfigFile(serverless); }) .then(serverlessConfigFile => { diff --git a/lib/utils/getServerlessConfigFile.js b/lib/utils/getServerlessConfigFile.js index 6277555e2ca..2847d383640 100644 --- a/lib/utils/getServerlessConfigFile.js +++ b/lib/utils/getServerlessConfigFile.js @@ -4,6 +4,7 @@ const _ = require('lodash'); const BbPromise = require('bluebird'); const path = require('path'); const resolveModulePath = require('ncjsm/resolve'); +const memoizee = require('memoizee'); const spawn = require('child-process-ext/spawn'); const fileExists = require('./fs/fileExists'); const readFile = require('./fs/readFile'); @@ -107,25 +108,23 @@ const handleJsOrTsConfigFile = configFile => } }); -const getServerlessConfigFile = _.memoize( - serverless => - getServerlessConfigFilePath(serverless).then(configFilePath => { - if (!configFilePath) return null; - const fileExtension = path.extname(configFilePath); - const isJSOrTsConfigFile = fileExtension === '.js' || fileExtension === '.ts'; +const getServerlessConfigFile = memoizee(serverless => + getServerlessConfigFilePath(serverless).then(configFilePath => { + if (!configFilePath) return null; + const fileExtension = path.extname(configFilePath); + const isJSOrTsConfigFile = fileExtension === '.js' || fileExtension === '.ts'; - return (isJSOrTsConfigFile - ? handleJsOrTsConfigFile(configFilePath) - : readFile(configFilePath) - ).then(config => { - if (_.isPlainObject(config)) return config; - throw new ServerlessError( - `${path.basename(configFilePath)} must export plain object`, - 'INVALID_CONFIG_OBJECT_TYPE' - ); - }); - }), - serverless => `${serverless.processedInput.options.config} - ${serverless.config.servicePath}` + return (isJSOrTsConfigFile + ? handleJsOrTsConfigFile(configFilePath) + : readFile(configFilePath) + ).then(config => { + if (_.isPlainObject(config)) return config; + throw new ServerlessError( + `${path.basename(configFilePath)} must export plain object`, + 'INVALID_CONFIG_OBJECT_TYPE' + ); + }); + }) ); module.exports = { getConfigFilePath, getServerlessConfigFile, getServerlessConfigFilePath };