Skip to content

Commit 46af78a

Browse files
committedMar 12, 2025·
Fix bun run [entry] (resolves #982)
1 parent 9cbb6b6 commit 46af78a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎packages/knip/src/binaries/package-manager/bun.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export const resolve: BinaryResolver = (_binary, args, options) => {
1919
const { manifestScriptNames, cwd, fromArgs } = options;
2020

2121
if (command === 'run' && manifestScriptNames.has(script)) return [];
22-
if (manifestScriptNames.has(command) || commands.includes(command)) return [];
22+
if (manifestScriptNames.has(command)) return [];
23+
if (command !== 'run' && commands.includes(command)) return [];
24+
2325
const filePath = command === 'run' ? script : command;
2426
const absFilePath = isAbsolute(filePath) ? filePath : join(cwd, filePath);
2527
if (isFile(absFilePath)) return [toEntry(absFilePath)];

‎packages/knip/test/util/get-inputs-from-scripts.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ test('getInputsFromScripts (bunx/bun x)', () => {
166166
t('bunx cowsay "Hello world!"', [toDependency('cowsay', optional)]);
167167
t('bunx my-cli --foo bar', [toDependency('my-cli', optional)]);
168168
t('bun x pkg', [toDependency('pkg', optional)]);
169+
t('bun ./main.ts', [toEntry(resolve(cwd, 'main.ts'))]);
170+
t('bun run script.js', [toEntry(resolve(cwd, 'script.js'))]);
169171
});
170172

171173
test('getInputsFromScripts (pnpm)', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.