Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/templating/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import chalk from 'chalk';

export async function downloadTemplate(
templateName: string,
bundleName: string,
namespace: string,
targetDirectory: string
): Promise<void> {
const files = await getTemplateFiles(templateName);
try {
await writeFiles(files, targetDirectory, bundleName);
console.log(chalk`{green SUCCESS} Created new bundle ${bundleName}`);
await writeFiles(files, targetDirectory, namespace);
console.log(
chalk`{green SUCCESS} Downloaded new template into the "${namespace}" subdirectories`
);
} catch (err) {
console.error(chalk`{red ERROR} ${err.message}`);
}
Expand Down
10 changes: 5 additions & 5 deletions src/templating/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function hasFilesOfType(files: TemplateFileInfo[], type: string) {
export async function writeFiles(
files: TemplateFileInfo[],
targetDir: string,
bundleName: string
namespace: string
): Promise<void> {
const functionsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [
'functions',
Expand All @@ -94,8 +94,8 @@ export async function writeFiles(
'assets',
'static',
]);
const functionsTargetDir = path.join(functionsDir, bundleName);
const assetsTargetDir = path.join(assetsDir, bundleName);
const functionsTargetDir = path.join(functionsDir, namespace);
const assetsTargetDir = path.join(assetsDir, namespace);

if (functionsTargetDir !== functionsDir) {
if (hasFilesOfType(files, 'functions')) {
Expand All @@ -104,7 +104,7 @@ export async function writeFiles(
} catch (err) {
log(err);
throw new Error(
`Bundle with name "${bundleName}" already exists in "${functionsDir}"`
`Template with name "${namespace}" already exists in "${functionsDir}"`
);
}
}
Expand All @@ -115,7 +115,7 @@ export async function writeFiles(
} catch (err) {
log(err);
throw new Error(
`Bundle with name "${bundleName}" already exists in "${assetsDir}"`
`Template with name "${namespace}" already exists in "${assetsDir}"`
);
}
}
Expand Down