Skip to content

Commit cb59993

Browse files
authoredMar 18, 2025··
fix: add warning for empty scripts (#265)
1 parent 7e2dfb2 commit cb59993

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed
 

‎src/commands/nr.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ import { limitText } from '../utils'
1313
function readPackageScripts(ctx: RunnerContext | undefined) {
1414
// support https://www.npmjs.com/package/npm-scripts-info conventions
1515
const pkg = getPackageJSON(ctx)
16-
const scripts = pkg.scripts || {}
16+
const rawScripts = pkg.scripts || {}
1717
const scriptsInfo = pkg['scripts-info'] || {}
1818

19-
return Object.entries(scripts)
19+
const scripts = Object.entries(rawScripts)
2020
.filter(i => !i[0].startsWith('?'))
2121
.map(([key, cmd]) => ({
2222
key,
2323
cmd,
24-
description: scriptsInfo[key] || scripts[`?${key}`] || cmd,
24+
description: scriptsInfo[key] || rawScripts[`?${key}`] || cmd,
2525
}))
26+
27+
if (scripts.length === 0 && !ctx?.programmatic) {
28+
console.warn('No scripts found in package.json')
29+
}
30+
31+
return scripts
2632
}
2733

2834
runCli(async (agent, args, ctx) => {

0 commit comments

Comments
 (0)
Please sign in to comment.