Skip to content

Commit

Permalink
Filter out ignored extensions from binaries in scripts + add .sh
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 12, 2023
1 parent 06a89bf commit 31ffb42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/binaries/index.ts
@@ -1,6 +1,7 @@
import { IGNORED_FILE_EXTENSIONS } from '../constants.js';
import { compact } from '../util/array.js';
import { getPackageNameFromModuleSpecifier } from '../util/modules.js';
import { isInternal } from '../util/path.js';
import { extname, isInternal } from '../util/path.js';
import { timerify } from '../util/Performance.js';
import { isBinary } from '../util/protocols.js';
import { getBinariesFromScript } from './bash-parser.js';
Expand All @@ -15,7 +16,12 @@ const getDependenciesFromScripts: GetDependenciesFromScripts = (npmScripts, opti

return compact(
results.map(identifier => {
if (isBinary(identifier) || isInternal(identifier)) return identifier;
if (isBinary(identifier)) return identifier;
if (isInternal(identifier)) {
const ext = extname(identifier);
if (ext && IGNORED_FILE_EXTENSIONS.includes(ext)) return;
return identifier;
}
return getPackageNameFromModuleSpecifier(identifier);
})
);
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Expand Up @@ -56,6 +56,7 @@ export const IGNORED_FILE_EXTENSIONS = [
'.sass',
'.scss',
'.svg',
'.sh',
'.ttf',
'.webp',
'.woff',
Expand Down

0 comments on commit 31ffb42

Please sign in to comment.