Skip to content

Commit 60c7729

Browse files
committedFeb 11, 2025··
Only console.log and write .gitignore file if update necessary
1 parent 1a5d732 commit 60c7729

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed
 

‎bin/install.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ try {
333333
// Swallow error if jsconfig.json file does not exist
334334
}
335335

336-
console.log('Updating .gitignore...');
337-
338336
const gitignorePath = join(process.cwd(), '.gitignore');
339337

340338
/** @type {string[]} */
@@ -346,22 +344,27 @@ try {
346344
// Swallow error in case .gitignore doesn't exist yet
347345
}
348346

347+
let gitignoreChanged = false;
348+
349349
for (const ignorePath of ['.eslintcache', '*.tsbuildinfo']) {
350350
if (gitignoreContentLines.includes(ignorePath)) {
351351
continue;
352352
}
353353

354354
gitignoreContentLines.push(ignorePath);
355+
gitignoreChanged = true;
355356
}
356357

357-
writeFileSync(
358-
gitignorePath,
359-
gitignoreContentLines.join('\n') +
360-
// Add trailing newline if last line is not empty
361-
(gitignoreContentLines.at(-1) === '' ? '' : '\n'),
362-
);
363-
364-
console.log('✅ Done updating .gitignore');
358+
if (gitignoreChanged) {
359+
console.log('Updating .gitignore...');
360+
writeFileSync(
361+
gitignorePath,
362+
gitignoreContentLines.join('\n') +
363+
// Add trailing newline if last line is not empty
364+
(gitignoreContentLines.at(-1) === '' ? '' : '\n'),
365+
);
366+
console.log('✅ Done updating .gitignore');
367+
}
365368

366369
const npmrcPath = join(process.cwd(), '.npmrc');
367370

0 commit comments

Comments
 (0)
Please sign in to comment.