From 7b3bf35f838abb26319701f39dae69ca8a7f981f Mon Sep 17 00:00:00 2001 From: Ana Silva Date: Wed, 21 Aug 2024 18:05:16 +0200 Subject: [PATCH] Asset types folders are fully copied with all the files inside --- src/devtools/main.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/devtools/main.ts b/src/devtools/main.ts index 2e95eb7..fe6521c 100644 --- a/src/devtools/main.ts +++ b/src/devtools/main.ts @@ -685,21 +685,23 @@ async function handleCopyToBuCMCommand(selectedPaths: string[]) { const buSelected: string[] = buOptions.map((bu: InputOptionsSettings) => bu.id); const filePathsConfigured: FileCopyConfig[] = supportedMetadataTypes - .map((configPath: DevToolsPathConfiguration) => { - const { absolutePath, businessUnit } = configPath; - + .map(({ absolutePath, businessUnit, metadataType, keys }: DevToolsPathConfiguration) => { if (businessUnit) { let paths: string[] = []; - - if (file.isPathADirectory(absolutePath)) { - paths = [...paths, absolutePath]; + // When the selected file to copy is inside a folder in asset type + // the whole folder and all files inside should be copied + if (metadataType === "asset" && keys.length > 2) { + const [_, assetKey]: string[] = keys; + paths.push(absolutePath.split(assetKey).shift() + assetKey); + } else if (file.isPathADirectory(absolutePath)) { + paths.push(absolutePath); } else { const [currentFileExt]: string[] = mainConfig.fileExtensions.filter( (fileExt: string) => absolutePath.endsWith(fileExt) ); if (currentFileExt) { - paths = [ - ...paths, + // Copies the same file for multiple extensions, eg sql & json + paths.push( ...file.fileExists( mainConfig.fileExtensions .filter( @@ -710,7 +712,7 @@ async function handleCopyToBuCMCommand(selectedPaths: string[]) { absolutePath.replace(currentFileExt, fileExtension) ) ) - ]; + ); } }