removed overwrite for file variable

This commit is contained in:
Eslam A. Hefnawy 2016-10-28 16:41:55 +07:00
parent 531e782dbb
commit cd260f0743
3 changed files with 7 additions and 7 deletions

View File

@ -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
};

View File

@ -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;
}

View File

@ -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);
});