Skip to content

Commit

Permalink
Skip setting hash if hash was not set previously (#1871)
Browse files Browse the repository at this point in the history
* Skip setting hash if hash was not set previously

* Add end to end test for installing a github package

* Update README.md

* Fix eslint

* Reverse accidental fixture changes

* Add unit tests

* No end to end tests for github installs
  • Loading branch information
thomaschaaf authored and bestander committed Nov 16, 2016
1 parent 32cf644 commit 1180f0f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
5 changes: 4 additions & 1 deletion __tests__/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ test.concurrent('install with arg', (): Promise<void> => {
return runAdd({}, ['is-online'], 'install-with-arg');
});

test.concurrent('install from github', (): Promise<void> => {
return runAdd({}, ['substack/node-mkdirp#master'], 'install-github');
});

test.concurrent('install with --dev flag', (): Promise<void> => {
return runAdd({dev: true}, ['left-pad@1.1.0'], 'add-with-flag', async (config) => {
const lockfile = explodeLockfile(await fs.readFile(path.join(config.cwd, 'yarn.lock')));
Expand Down Expand Up @@ -571,5 +575,4 @@ test.concurrent('add should generate correct integrity file', (): Promise<void>
}
expect(allCorrect).toBe(true);
});

});
4 changes: 4 additions & 0 deletions __tests__/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ test.concurrent('install from git cache', (): Promise<void> => {
});
});

test.concurrent('install from github', (): Promise<void> => {
return runInstall({}, 'install-github');
});

test.concurrent('install should dedupe dependencies avoiding conflicts 0', (): Promise<void> => {
// A@2.0.1 -> B@2.0.0
// B@1.0.0
Expand Down
10 changes: 1 addition & 9 deletions __tests__/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Config from '../../src/config.js';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;

const stream = require('stream');
const path = require('path');
const os = require('os');

Expand Down Expand Up @@ -48,14 +47,7 @@ async function runLs(
}
}

let out = '';
const stdout = new stream.Writable({
decodeStrings: false,
write(data, encoding, cb) {
out += data;
cb();
},
});
const out = '';

const reporter = new reporters.BufferReporter({stdout: null, stdin: null});

Expand Down
10 changes: 1 addition & 9 deletions __tests__/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;

const execCommand: $FlowFixMe = require('../../src/util/execute-lifecycle-script').execCommand;

const stream = require('stream');
const path = require('path');
const os = require('os');

Expand Down Expand Up @@ -40,14 +39,7 @@ async function runRun(
}
}

let out = '';
const stdout = new stream.Writable({
decodeStrings: false,
write(data, encoding, cb) {
out += data;
cb();
},
});
const out = '';

const reporter = new reporters.BufferReporter({stdout: null, stdin: null});

Expand Down
Empty file.
5 changes: 5 additions & 0 deletions __tests__/fixtures/install/install-github/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"mkdirp": "substack/node-mkdirp#master"
}
}
4 changes: 1 addition & 3 deletions src/cli/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import map from '../../util/map.js';
import {sortAlpha} from '../../util/misc.js';

const invariant = require('invariant');
const userHome = require('user-home');
const semver = require('semver');
const emoji = require('node-emoji');
const isCI = require('is-ci');
const path = require('path');
const fs2 = require('fs');

const {version: YARN_VERSION, installationMethod: YARN_INSTALL_METHOD} = require('../../../package.json');
const ONE_DAY = 1000 * 60 * 60 * 24;
Expand Down Expand Up @@ -97,7 +95,7 @@ function getUpdateCommand(): ?string {
}

if (YARN_INSTALL_METHOD === 'chocolatey') {
return 'choco upgrade yarn';
return 'choco upgrade yarn';
}

return null;
Expand Down
6 changes: 5 additions & 1 deletion src/package-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ export default class PackageFetcher {
newPkg = res.package;

// update with new remote
ref.remote.hash = res.hash;
// but only if there was a hash previously as the tarball fetcher does not provide a hash.
if (ref.remote.hash) {
ref.remote.hash = res.hash;
}

if (res.resolved) {
ref.remote.resolved = res.resolved;
}
Expand Down

0 comments on commit 1180f0f

Please sign in to comment.