Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bestander authored and arcanis committed Jun 23, 2017
1 parent c63e015 commit 68210a3
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
12 changes: 12 additions & 0 deletions __tests__/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,3 +819,15 @@ test.concurrent('should retain build artifacts after add', (): Promise<void> =>
'retain-build-artifacts-after-add',
);
});

test.concurrent('installing with --pure-lockfile and then adding should keep build artifacts', (): Promise<void> => {
const fixture = 'integrity-pure-lockfile';

return runInstall({pureLockfile: true}, path.join('..', 'add', fixture), async (config, reporter): Promise<void> => {
expect(await fs.exists(path.join(config.cwd, 'node_modules', '.yarn-integrity'))).toBe(true);
expect(await fs.exists(path.join(config.cwd, 'node_modules', 'package-a', 'temp.txt'))).toBe(true);
const add = new Add(['[email protected]'], {}, config, reporter, (await Lockfile.fromDirectory(config.cwd)));
await add.init();
expect(await fs.exists(path.join(config.cwd, 'node_modules', 'package-a', 'temp.txt'))).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "package-a",
"version": "1.0.0",
"scripts": {
"install": "node script.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var fs = require('fs');

fs.writeFileSync('temp.txt', 'TEST');
6 changes: 6 additions & 0 deletions __tests__/fixtures/add/integrity-pure-lockfile/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"package-a": "file:./package-a"
}
}
6 changes: 6 additions & 0 deletions __tests__/fixtures/add/integrity-pure-lockfile/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"package-a@file:./package-a":
version "1.0.0"
10 changes: 5 additions & 5 deletions src/cli/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,6 @@ export class Install {
*/

async saveLockfileAndIntegrity(patterns: Array<string>, workspaceLayout: ?WorkspaceLayout): Promise<void> {
// --no-lockfile or --pure-lockfile flag
if (this.flags.lockfile === false || this.flags.pureLockfile) {
return;
}

const resolvedPatterns: {[packagePattern: string]: Manifest} = {};
Object.keys(this.resolver.patterns).forEach(pattern => {
if (!workspaceLayout || !workspaceLayout.getManifestByPattern(pattern)) {
Expand All @@ -667,6 +662,11 @@ export class Install {
this.scripts.getArtifacts(),
);

// --no-lockfile or --pure-lockfile flag
if (this.flags.lockfile === false || this.flags.pureLockfile) {
return;
}

const lockFileHasAllPatterns = patterns.every(p => this.lockfile.getLocked(p));
const resolverPatternsAreSameAsInLockfile = Object.keys(lockfileBasedOnResolver).every(pattern => {
const manifest = this.lockfile.getLocked(pattern);
Expand Down

0 comments on commit 68210a3

Please sign in to comment.