Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes integrity check for --production flag #3067

Merged
merged 3 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __tests__/commands/install/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,3 +800,15 @@ test.concurrent('prunes the offline mirror after pruning is enabled', (): Promis
expect(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-b-1.0.0.tgz`))).toEqual(false);
});
});

test.concurrent('bailout should work with --production flag too', (): Promise<void> => {
return runInstall({production: true}, 'bailout-prod', async (config, reporter): Promise<void> => {
// remove file
await fs.unlink(path.join(config.cwd, 'node_modules', 'left-pad', 'index.js'));
// run install again
const reinstall = new Install({production: true}, config, reporter, await Lockfile.fromDirectory(config.cwd));
await reinstall.init();
// don't expect file being recreated because install should have bailed out
expect(await fs.exists(path.join(config.cwd, 'node_modules', 'left-pad', 'index.js'))).toBe(false);
});
});
8 changes: 8 additions & 0 deletions __tests__/fixtures/install/bailout-prod/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"left-pad": "^1.1.3"
},
"devDependencies": {
"is-array": "^1.0.1"
}
}
11 changes: 11 additions & 0 deletions __tests__/fixtures/install/bailout-prod/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


is-array@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-array/-/is-array-1.0.1.tgz#e9850cc2cc860c3bc0977e84ccf0dd464584279a"

left-pad@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a"
3 changes: 1 addition & 2 deletions src/cli/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ export class Install {
requests: depRequests,
patterns: rawPatterns,
ignorePatterns,
usedPatterns,
} = await this.fetchRequestFromCwd();
let topLevelPatterns: Array<string> = [];

Expand All @@ -394,7 +393,7 @@ export class Install {
await this.resolver.init(this.prepareRequests(depRequests), this.flags.flat);
topLevelPatterns = this.preparePatterns(rawPatterns);
flattenedTopLevelPatterns = await this.flatten(topLevelPatterns);
return {bailout: await this.bailout(usedPatterns)};
return {bailout: await this.bailout(topLevelPatterns)};
});

steps.push(async (curr: number, total: number) => {
Expand Down