Skip to content

Commit 045c378

Browse files
authored
fix(mama): always remove ./node_modules/.bin from integrity hash (#513)
1 parent 979c469 commit 045c378

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

.changeset/violet-trains-argue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nodesecure/mama": patch
3+
---
4+
5+
Always remove ./bin/node_modules from hash integrity

workspaces/mama/src/utils/integrity-hash.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ export function packageJSONIntegrityHash(
5656
* Note: NPM registry automatically add `./node_modules/.bin/` to scripts
5757
* This artifact do not concern raw scripts in the tarball package.json.
5858
*/
59-
scripts: isFromRemoteRegistry ?
60-
removeNodeModulesBin(scripts) :
61-
scripts
59+
scripts: removeNodeModulesBin(scripts)
6260
};
6361

6462
return {

workspaces/mama/test/packageJSONIntegrityHash.spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@ describe("packageJSONIntegrityHash", () => {
5050
});
5151

5252
test("Given a script with an instance of './node_modules/.bin/'", () => {
53-
const { object } = packageJSONIntegrityHash({
54-
...kMinimalPackageJSON,
55-
scripts: {
56-
test: "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/integration/*.js"
57-
}
58-
}, { isFromRemoteRegistry: true });
53+
for (const arg of [undefined, { isFromRemoteRegistry: true }]) {
54+
const { object } = packageJSONIntegrityHash({
55+
...kMinimalPackageJSON,
56+
scripts: {
57+
test: "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/integration/*.js"
58+
}
59+
}, arg);
5960

60-
assert.strictEqual(
61-
object.scripts.test,
62-
"istanbul cover ./node_modules/tape/bin/tape ./test/integration/*.js"
63-
);
61+
assert.strictEqual(
62+
object.scripts.test,
63+
"istanbul cover ./node_modules/tape/bin/tape ./test/integration/*.js"
64+
);
65+
}
6466
});
6567
});

0 commit comments

Comments
 (0)