Skip to content

Commit

Permalink
fix: restore global predicate on install (#26)
Browse files Browse the repository at this point in the history
fix max-overall-size + regretion test for #25
  • Loading branch information
AdrieanKhisbe committed Mar 17, 2020
1 parent 4078266 commit dd8bf14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const main = async ({

const statuses = await pMap(packages, async paquage => {
const stats = await fetchPackageStats(paquage).catch(handleError(paquage, true));
return _.set('package', paquage, predicate(stats));
return _.defaultsAll([{package: paquage}, stats, predicate(stats)]);
});

const toInstallStats = aggregateStats(statuses);
Expand Down
29 changes: 29 additions & 0 deletions test/integration/install.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Integrations tests', () => {
);
expect(exec.retrieveCmd()).toEqual('npm install bytes@3.0.0');
});

it('install just a single package and just warn', async () => {
const stream = fakeStream();
const exec = fakeExec();
Expand Down Expand Up @@ -139,4 +140,32 @@ describe('Integrations tests', () => {
);
}
});

it('install just a single package on empty package with global config and succeed', async () => {
const stream = fakeStream();
const exec = fakeExec();

await main({
argv: {_: ['bytes@3.0.0']},
stream,
exec,
defaultMaxSize,
readPkg: () => ({
dependencies: {},
'bundle-phobia': {
'max-size': '20kB',
'max-overall-size': '50kB'
}
})
});

expect(stream.getContent()).toEqual(
`ℹ Applying a size limit of 20KB from package-config and overall size limit of 50KB from package-config
- Fetching stats for package bytes@3.0.0
ℹ Proceed to installation of package bytes@3.0.0
`
);
expect(exec.retrieveCmd()).toEqual('npm install bytes@3.0.0');
});
});

0 comments on commit dd8bf14

Please sign in to comment.