From 95020c234d26e93068b745d4950af46661907301 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 31 Jul 2019 11:09:50 +1000 Subject: [PATCH] refactor: renames "bundle" to "namespace" when downloading templates --- src/templating/actions.ts | 8 +++++--- src/templating/filesystem.ts | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/templating/actions.ts b/src/templating/actions.ts index 051b5305..89c02ca5 100644 --- a/src/templating/actions.ts +++ b/src/templating/actions.ts @@ -4,13 +4,15 @@ import chalk from 'chalk'; export async function downloadTemplate( templateName: string, - bundleName: string, + namespace: string, targetDirectory: string ): Promise { 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}`); } diff --git a/src/templating/filesystem.ts b/src/templating/filesystem.ts index 1ec4b1b6..e15bdb41 100644 --- a/src/templating/filesystem.ts +++ b/src/templating/filesystem.ts @@ -84,7 +84,7 @@ function hasFilesOfType(files: TemplateFileInfo[], type: string) { export async function writeFiles( files: TemplateFileInfo[], targetDir: string, - bundleName: string + namespace: string ): Promise { const functionsDir = fsHelpers.getFirstMatchingDirectory(targetDir, [ 'functions', @@ -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')) { @@ -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}"` ); } } @@ -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}"` ); } }