Skip to content

Commit

Permalink
trimming trailing white space
Browse files Browse the repository at this point in the history
  • Loading branch information
eahefnawy committed Aug 30, 2016
1 parent 45353bc commit ce2ce4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/classes/Utils.js
Expand Up @@ -74,7 +74,7 @@ class Utils {
} else if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) {
contents = YAML.load(contents.toString());
} else {
contents = contents.toString();
contents = contents.toString().trim();
}

return contents;
Expand Down
14 changes: 14 additions & 0 deletions tests/classes/Variables.js
Expand Up @@ -335,6 +335,20 @@ describe('Service', () => {
expect(valueToPopulate).to.equal('hello world');
});

it('should trim trailing whitespace and new line character', () => {
const serverless = new Serverless();
const SUtils = new Utils();
const tmpDirPath = testUtils.getTmpDirPath();

SUtils.writeFileSync(path.join(tmpDirPath, 'someFile'),
'hello world \n');

serverless.config.update({ servicePath: tmpDirPath });

const valueToPopulate = serverless.variables.getValueFromFile('file(./someFile)');
expect(valueToPopulate).to.equal('hello world');
});

it('should populate from another file when variable is of any type', () => {
const serverless = new Serverless();
const SUtils = new Utils();
Expand Down

0 comments on commit ce2ce4a

Please sign in to comment.