Skip to content

Commit 2da1fe0

Browse files
authoredFeb 11, 2025··
Configure strict-dep-builds to fail on pnpm v10 ignored build scripts (#490)
* Configure strict-dep-builds to fail on pnpm v10 ignored build scripts * Move URL to own line and bullet
1 parent 0d10933 commit 2da1fe0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 

‎bin/install.js

+25
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,31 @@ writeFileSync(
363363

364364
console.log('✅ Done updating .gitignore');
365365

366+
const npmrcPath = join(process.cwd(), '.npmrc');
367+
368+
/** @type {string[]} */
369+
let npmrcContentLines = [];
370+
371+
try {
372+
npmrcContentLines = readFileSync(npmrcPath, 'utf-8').split('\n');
373+
} catch {
374+
// Swallow error in case .npmrc doesn't exist yet
375+
}
376+
377+
if (!npmrcContentLines.includes('strict-dep-builds=true')) {
378+
console.log('Updating .npmrc...');
379+
npmrcContentLines.push(`# Fail on pnpm ignored build scripts
380+
# - https://github.com/pnpm/pnpm/pull/9071
381+
strict-dep-builds=true`);
382+
writeFileSync(
383+
npmrcPath,
384+
npmrcContentLines.join('\n') +
385+
// Add trailing newline if last line is not empty
386+
(npmrcContentLines.at(-1) === '' ? '' : '\n'),
387+
);
388+
console.log('✅ Done updating .npmrc');
389+
}
390+
366391
// Commented out in case we need to patch Next.js again in the
367392
// future
368393
// ```

0 commit comments

Comments
 (0)
Please sign in to comment.