Skip to content

Commit 7b94343

Browse files
committed
fix: handle binaries with dots
1 parent 27f9274 commit 7b94343

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

app/utils/install-scripts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const INSTALL_SCRIPTS = new Set(['preinstall', 'install', 'postinstall'])
1212

1313
// Pattern to match npx commands with various flags
1414
// Captures the package name (with optional scope and version)
15-
const NPX_PATTERN = /\bnpx\s+(?:--?\w+(?:=\S+)?\s+)*(@?[\w-]+(?:\/[\w-]+)?(?:@[\w.^~<>=|-]+)?)/g
15+
const NPX_PATTERN = /\bnpx\s+(?:--?\w+(?:=\S+)?\s+)*(@?[\w.-]+(?:\/[\w.-]+)?(?:@[\w.^~<>=|-]+)?)/g
1616

1717
// Pattern to extract package name and version from captured group
18-
const PACKAGE_VERSION_PATTERN = /^(@[\w-]+\/[\w-]+|[\w-]+)(?:@(.+))?$/
18+
const PACKAGE_VERSION_PATTERN = /^(@[\w.-]+\/[\w.-]+|[\w.-]+)(?:@(.+))?$/
1919

2020
/**
2121
* Extract packages from npx calls in install scripts.

test/unit/install-scripts.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,19 @@ describe('extractInstallScriptsInfo', () => {
5959
npxDependencies: {},
6060
})
6161
})
62+
63+
it('extracts npx packages with dots in names', () => {
64+
const scripts = {
65+
postinstall: 'npx vue.js@3.0.0 && npx @scope/pkg.name generate',
66+
}
67+
const result = extractInstallScriptsInfo(scripts)
68+
expect(result).toEqual({
69+
scripts: ['postinstall'],
70+
content: { postinstall: 'npx vue.js@3.0.0 && npx @scope/pkg.name generate' },
71+
npxDependencies: {
72+
'vue.js': '3.0.0',
73+
'@scope/pkg.name': 'latest',
74+
},
75+
})
76+
})
6277
})

0 commit comments

Comments
 (0)