Skip to content

Commit

Permalink
fix: creating .gitignor from constant string
Browse files Browse the repository at this point in the history
  • Loading branch information
DanilSord committed Mar 13, 2022
1 parent 1e687b8 commit 7f564f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const files = {
'docker-compose.yml': [],
'.prettierrc.json': [],
'.prettierignore': [],
'.gitignore': [],
'.gitignore': 'node_modules',
'.eslintrc': [],
'.eslintignore': [],
'.editorconfig': [],
Expand Down
16 changes: 10 additions & 6 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ const createFiles = async (directory, localPath, files, values) => {
createPath(directory);
for (const fileName in files) {
const file = files[fileName];
let data = fs.readFileSync(path.resolve(localPath, fileName), { encoding: 'utf-8' });
for (const param of file) {
if (typeof param === 'object') {
data = data.replaceAll(`$${param.name}$`, param.convert(values[param.name]));
} else {
data = data.replaceAll(`$${param}$`, values[param]);
let data = '';
if (fileName === '.gitignore') data = file;
else {
data = fs.readFileSync(path.resolve(localPath, fileName), { encoding: 'utf-8' });
for (const param of file) {
if (typeof param === 'object') {
data = data.replaceAll(`$${param.name}$`, param.convert(values[param.name]));
} else {
data = data.replaceAll(`$${param}$`, values[param]);
}
}
}
createPath(path.resolve(directory, fileName));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "DonVietnam",
"email": "[email protected]"
},
"version": "1.0.1",
"version": "1.0.2",
"description": "Cli tool for generating projects templates.",
"license": "MIT",
"keywords": [
Expand Down

0 comments on commit 7f564f6

Please sign in to comment.