Skip to content

Commit

Permalink
fix(dotfiles): Renamed dotfiles in order to be copied
Browse files Browse the repository at this point in the history
Dotfiles are not copied by default so i'm renaming then with _ and then moving them once the folder
its created
  • Loading branch information
izifortune committed Nov 23, 2017
1 parent 29df013 commit a1417f5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/new.command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
copy,
ensureDir,
move,
readFile,
readJSON,
writeFile,
Expand Down Expand Up @@ -30,6 +31,8 @@ const TEMPLATE_FILES = [
'modules/feature/src/basket.module.ts'
];

const DOT_FILES = ['_angular-cli.json', '_editorconfig', '_gitignore'];

/**
* Replace occurencies of the KEY with the value passed
*/
Expand All @@ -40,6 +43,14 @@ async function replace(filePath: string, KEY: string, value: string) {
return writeFile(filePath, res);
}

async function renameDotFiles(basePath: string) {
return Promise.all(
DOT_FILES.map(file =>
move(join(basePath, file), join(basePath, file.replace('_', '.')))
)
);
}

/**
* Replace occurencies of all the TEMPLATE_VARS inside a file
* with the matching values passed.
Expand Down Expand Up @@ -67,6 +78,8 @@ export async function newCommand(

const values = [answers.scope, answers.scope.replace('@', ''), args.name];

await renameDotFiles(args.name);

await execTask('Replace templates', () =>
Promise.all(
TEMPLATE_FILES.map(file => replaceForFile(join(args.name, file), values))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a1417f5

Please sign in to comment.