Tests for fixing #7021 to ensure file permissions are copied when templating
Signed-off-by: Christopher Zorn <czorn@flexport.com>
This commit is contained in:
@@ -146,6 +146,10 @@ describe('fetch:template', () => {
|
||||
mockFetchContents.mockImplementation(({ outputPath }) => {
|
||||
mockFs({
|
||||
[outputPath]: {
|
||||
'an-executable.sh': mockFs.file({
|
||||
content: '#!/usr/bin/env bash',
|
||||
mode: parseInt('100755', 8),
|
||||
}),
|
||||
'empty-dir-${{ values.count }}': {},
|
||||
'static.txt': 'static content',
|
||||
'${{ values.name }}.txt': 'static content',
|
||||
@@ -211,6 +215,13 @@ describe('fetch:template', () => {
|
||||
fs.readFile(`${workspacePath}/target/a-binary-file.png`),
|
||||
).resolves.toEqual(aBinaryFile);
|
||||
});
|
||||
it('copies files and maintains the original file permissions', async () => {
|
||||
await expect(
|
||||
fs
|
||||
.stat(`${workspacePath}/target/an-executable.sh`)
|
||||
.then(fObj => fObj.mode),
|
||||
).resolves.toEqual(parseInt('100755', 8));
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyWithoutRender', () => {
|
||||
|
||||
@@ -272,8 +272,8 @@ export function createFetchTemplateAction(options: {
|
||||
renderContents
|
||||
? templater.renderString(inputFileContents, context)
|
||||
: inputFileContents,
|
||||
{ mode: statsObj.mode },
|
||||
);
|
||||
await fs.chmod(outputPath, statsObj.mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user