Skip to content

Commit

Permalink
fixes yarnpkg#3506
Browse files Browse the repository at this point in the history
  • Loading branch information
bestander committed Jun 23, 2017
1 parent f404b62 commit 0265b11
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 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
6 changes: 1 addition & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2712,14 +2712,10 @@ istanbul-api@^1.1.0-alpha.1:
mkdirp "^0.5.1"
once "^1.4.0"

istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.1.1:
istanbul-lib-coverage@^1.0.0, istanbul-lib-coverage@^1.1.0, istanbul-lib-coverage@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da"

istanbul-lib-coverage@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz#caca19decaef3525b5d6331d701f3f3b7ad48528"

istanbul-lib-hook@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.0.7.tgz#dd6607f03076578fe7d6f2a630cf143b49bacddc"
Expand Down

0 comments on commit 0265b11

Please sign in to comment.