Skip to content

Commit

Permalink
Only console.log and write .gitignore file if update necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Feb 11, 2025
1 parent 1a5d732 commit 60c7729
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ try {
// Swallow error if jsconfig.json file does not exist
}

console.log('Updating .gitignore...');

const gitignorePath = join(process.cwd(), '.gitignore');

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

let gitignoreChanged = false;

for (const ignorePath of ['.eslintcache', '*.tsbuildinfo']) {
if (gitignoreContentLines.includes(ignorePath)) {
continue;
}

gitignoreContentLines.push(ignorePath);
gitignoreChanged = true;
}

writeFileSync(
gitignorePath,
gitignoreContentLines.join('\n') +
// Add trailing newline if last line is not empty
(gitignoreContentLines.at(-1) === '' ? '' : '\n'),
);

console.log('✅ Done updating .gitignore');
if (gitignoreChanged) {
console.log('Updating .gitignore...');
writeFileSync(
gitignorePath,
gitignoreContentLines.join('\n') +
// Add trailing newline if last line is not empty
(gitignoreContentLines.at(-1) === '' ? '' : '\n'),
);
console.log('✅ Done updating .gitignore');
}

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

Expand Down

0 comments on commit 60c7729

Please sign in to comment.