mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
removed overwrite for file variable
This commit is contained in:
parent
531e782dbb
commit
cd260f0743
@ -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
|
||||
};
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user