Skip to content

Commit 7f564f6

Browse files
author
DanilSord
committed
fix: creating .gitignor from constant string
1 parent 1e687b8 commit 7f564f6

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

lib/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const files = {
2828
'docker-compose.yml': [],
2929
'.prettierrc.json': [],
3030
'.prettierignore': [],
31-
'.gitignore': [],
31+
'.gitignore': 'node_modules',
3232
'.eslintrc': [],
3333
'.eslintignore': [],
3434
'.editorconfig': [],

lib/utils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ const createFiles = async (directory, localPath, files, values) => {
2222
createPath(directory);
2323
for (const fileName in files) {
2424
const file = files[fileName];
25-
let data = fs.readFileSync(path.resolve(localPath, fileName), { encoding: 'utf-8' });
26-
for (const param of file) {
27-
if (typeof param === 'object') {
28-
data = data.replaceAll(`$${param.name}$`, param.convert(values[param.name]));
29-
} else {
30-
data = data.replaceAll(`$${param}$`, values[param]);
25+
let data = '';
26+
if (fileName === '.gitignore') data = file;
27+
else {
28+
data = fs.readFileSync(path.resolve(localPath, fileName), { encoding: 'utf-8' });
29+
for (const param of file) {
30+
if (typeof param === 'object') {
31+
data = data.replaceAll(`$${param.name}$`, param.convert(values[param.name]));
32+
} else {
33+
data = data.replaceAll(`$${param}$`, values[param]);
34+
}
3135
}
3236
}
3337
createPath(path.resolve(directory, fileName));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "DonVietnam",
55
"email": "don.vietnam.js@gmail.com"
66
},
7-
"version": "1.0.1",
7+
"version": "1.0.2",
88
"description": "Cli tool for generating projects templates.",
99
"license": "MIT",
1010
"keywords": [

0 commit comments

Comments
 (0)