From cd260f074324332dc17cda95d4b59d0ede07dfbd Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Fri, 28 Oct 2016 16:41:55 +0700 Subject: [PATCH] removed overwrite for file variable --- docs/providers/aws/examples/cron/node/handler.js | 2 +- lib/classes/Variables.js | 10 +++++----- lib/classes/Variables.test.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/providers/aws/examples/cron/node/handler.js b/docs/providers/aws/examples/cron/node/handler.js index 5fb485788..980b35d28 100644 --- a/docs/providers/aws/examples/cron/node/handler.js +++ b/docs/providers/aws/examples/cron/node/handler.js @@ -2,5 +2,5 @@ module.exports.run = () => { const time = new Date(); - console.log(`Your cron ran ${time}`); + console.log(`Your cron ran ${time}`); // eslint-disable-line no-console }; diff --git a/lib/classes/Variables.js b/lib/classes/Variables.js index 99773e7b0..f8aa0039c 100644 --- a/lib/classes/Variables.js +++ b/lib/classes/Variables.js @@ -101,7 +101,7 @@ class Variables { let finalValue; const variableStringsArray = variableStringsString.split(','); variableStringsArray.find(variableString => { - finalValue = this.getValueFromSource(variableString, true); + finalValue = this.getValueFromSource(variableString); return (finalValue !== null && typeof finalValue !== 'undefined') && !(typeof finalValue === 'object' && _.isEmpty(finalValue)); }); @@ -109,7 +109,7 @@ class Variables { return finalValue; } - getValueFromSource(variableString, overwriteMode) { + getValueFromSource(variableString) { let valueToPopulate; if (variableString.match(this.envRefSyntax)) { valueToPopulate = this.getValueFromEnv(variableString); @@ -118,7 +118,7 @@ class Variables { } else if (variableString.match(this.selfRefSyntax)) { valueToPopulate = this.getValueFromSelf(variableString); } else if (variableString.match(this.fileRefSyntax)) { - valueToPopulate = this.getValueFromFile(variableString, overwriteMode); + valueToPopulate = this.getValueFromFile(variableString); } else { const errorMessage = [ `Invalid variable reference syntax for variable ${variableString}.`, @@ -149,14 +149,14 @@ class Variables { return valueToPopulate; } - getValueFromFile(variableString, overwriteMode) { + getValueFromFile(variableString) { const matchedFileRefString = variableString.match(this.fileRefSyntax)[0]; const referencedFileRelativePath = matchedFileRefString .replace(this.fileRefSyntax, (match, varName) => varName.trim()); const referencedFileFullPath = path.join(this.serverless.config.servicePath, referencedFileRelativePath); - if (overwriteMode === true && !this.serverless.utils.fileExistsSync(referencedFileFullPath)) { + if (!this.serverless.utils.fileExistsSync(referencedFileFullPath)) { return undefined; } diff --git a/lib/classes/Variables.test.js b/lib/classes/Variables.test.js index cfe5e0f15..2caec549a 100644 --- a/lib/classes/Variables.test.js +++ b/lib/classes/Variables.test.js @@ -391,7 +391,7 @@ describe('Variables', () => { serverless.config.update({ servicePath: tmpDirPath }); - const valueToPopulate = serverless.variables.getValueFromFile('file(./config.yml)', true); + const valueToPopulate = serverless.variables.getValueFromFile('file(./config.yml)'); expect(valueToPopulate).to.be.equal(undefined); });