Fix issues with empty directories and files
Signed-off-by: Manuel Cañete <mcaneteubeda@gmail.com>
This commit is contained in:
committed by
Manuel Cañete
parent
1bf1ef7e5a
commit
1d17902107
@@ -206,16 +206,17 @@ export function createFetchTemplateAction(options: {
|
||||
} else {
|
||||
renderFilename = renderContents = !nonTemplatedEntries.has(location);
|
||||
}
|
||||
|
||||
if (renderFilename) {
|
||||
localOutputPath = renderTemplate(localOutputPath, context);
|
||||
}
|
||||
const outputPath = resolveSafeChildPath(outputDir, localOutputPath);
|
||||
// variables have been expanded to make an empty file name
|
||||
// this is due to a conditional like if values.my_condition then file-name.txt else empty string so skip
|
||||
if (outputDir === outputPath) {
|
||||
|
||||
if (containsSkippedContent(localOutputPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const outputPath = resolveSafeChildPath(outputDir, localOutputPath);
|
||||
|
||||
if (!renderContents && !extension) {
|
||||
ctx.logger.info(
|
||||
`Copying file/directory ${location} without processing.`,
|
||||
@@ -257,3 +258,12 @@ export function createFetchTemplateAction(options: {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function containsSkippedContent(localOutputPath: string): boolean {
|
||||
// if the path starts with / means that the root directory has been skipped
|
||||
// if the path is empty means that there is a file skipped in the root
|
||||
// if the path includes // means that there is a subdirectory skipped
|
||||
return localOutputPath.startsWith('/')
|
||||
|| localOutputPath === ''
|
||||
|| localOutputPath.includes('//');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user