@@ -49,6 +49,8 @@ const readFile = jest.fn(async (path: string) => {
|
||||
const content = (
|
||||
{
|
||||
[resolvePath(root, 'my-secret')]: 'secret',
|
||||
[resolvePath(root, 'with-newline-at-the-end')]:
|
||||
'value without newline at the end\n',
|
||||
[resolvePath(root, 'my-data.json')]: '{"a":{"b":{"c":42}}}',
|
||||
[resolvePath(root, 'my-data.yaml')]: 'some:\n yaml:\n key: 7',
|
||||
[resolvePath(root, 'my-data.yml')]: 'different: { key: hello }',
|
||||
@@ -92,6 +94,14 @@ describe('includeTransform', () => {
|
||||
includeTransform({ $file: 'no-secret' }, root),
|
||||
).rejects.toThrow('File not found!');
|
||||
});
|
||||
it('should trim new lines from end of file', async () => {
|
||||
await expect(
|
||||
includeTransform({ $file: 'with-newline-at-the-end' }, root),
|
||||
).resolves.toEqual({
|
||||
applied: true,
|
||||
value: 'value without new line at the end',
|
||||
});
|
||||
});
|
||||
|
||||
it('should include env vars', async () => {
|
||||
await expect(includeTransform({ $env: 'SECRET' }, root)).resolves.toEqual({
|
||||
|
||||
@@ -73,7 +73,7 @@ export function createIncludeTransform(
|
||||
case '$file':
|
||||
try {
|
||||
const value = await readFile(resolvePath(baseDir, includeValue));
|
||||
return { applied: true, value };
|
||||
return { applied: true, value: value.trimEnd() };
|
||||
} catch (error) {
|
||||
throw new Error(`failed to read file ${includeValue}, ${error}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user