Skip to content

Commit

Permalink
Merge 51828d9 into 527104b
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine committed May 30, 2019
2 parents 527104b + 51828d9 commit 3372034
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class System {
*/
hasInstance(instance) {
const instances = this.globalConfig.get('instances', {});
return some(instances, ({cwd}) => cwd === instance.dir);
return some(instances, ({cwd}, name) => cwd === instance.dir && name === instance.name);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion test/unit/system-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,17 @@ describe('Unit: System', function () {
it('hasInstance works', function () {
const System = require(modulePath);
const system = new System({}, []);
system.globalConfig.set('instances', {test: {cwd: '/dir/a'}});
system.globalConfig.set('instances', {test: {cwd: '/dir/a'}, test2: {cwd: '/dir/c'}});
const instanceA = new Instance({}, system, '/dir/a');
instanceA._cliConfig.set('name', 'test');

const instanceB = new Instance({}, system, '/dir/b');
const instanceC = new Instance({}, system, '/dir/c');
instanceC._cliConfig.set('name', 'different');

expect(system.hasInstance(instanceA)).to.be.true;
expect(system.hasInstance(instanceB)).to.be.false;
expect(system.hasInstance(instanceC)).to.be.false;
});

it('cachedInstance loads instance and caches it', function () {
Expand Down

0 comments on commit 3372034

Please sign in to comment.