Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit fc48f25

Browse files
committed
test: validate semver
1 parent 73db129 commit fc48f25

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/dominykas/allow-scripts.git"
88
},
99
"scripts": {
10-
"test": "lab -L -t 80 -m 5000"
10+
"test": "lab -L -t 83 -m 5000"
1111
},
1212
"bin": {
1313
"allow-scripts": "./bin/allow-scripts.js"

test/fixtures/allowed-semver.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"private": true,
3+
"name": "@example/allowed-false",
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@example/with-install-script": "*",
7+
"@example/with-postinstall-script": "*",
8+
"@example/without-scripts": "*"
9+
},
10+
"allowScripts": {
11+
"@example/with-install-script": "1.x.x",
12+
"@example/with-postinstall-script": "*"
13+
}
14+
}

test/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,20 @@ describe('allow-scripts', () => {
7070
expect(fixture.getActualResult()).to.equal('postinstall from with-postinstall-script');
7171
expect(fixture.getLog()).to.contain('skip node_modules/@example/with-install-script (because it is not allowed in package.json)');
7272
});
73+
74+
it('skips scripts which are outside of allowed semver range', async () => {
75+
76+
const fixture = Fixtures.setup('allowed-semver', [
77+
'with-install-script',
78+
'with-postinstall-script',
79+
'without-scripts'
80+
]);
81+
82+
await Allow.run({});
83+
84+
expect(fixture.getActualResult()).not.to.contain('with-install-script');
85+
expect(fixture.getActualResult()).to.equal('postinstall from with-postinstall-script');
86+
expect(fixture.getLog()).to.contain('skip node_modules/@example/with-install-script (because 0.0.0 is outside of allowed range: 1.x.x)');
87+
});
7388
});
7489
});

0 commit comments

Comments
 (0)