Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
fix(package condition): Check if package is loaded not just active
Browse files Browse the repository at this point in the history
fixes #158
  • Loading branch information
UziTech committed Aug 5, 2019
1 parent 009163f commit b248b1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/flex-tool-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ export default {

packageCondition(condition) {
this.conditionTypes.package = true;
return this.reversableStringCondition(condition, (c) => atom.packages.isPackageActive(c));
return this.reversableStringCondition(condition, (c) => (atom.packages.isPackageLoaded(c) && !atom.packages.isPackageDisabled(c)));
},

settingCondition(condition) {
Expand Down
19 changes: 19 additions & 0 deletions spec/flex-tool-bar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,25 @@ describe('FlexToolBar', function () {
expect(notMatch).toBe(false);
expect(match).toBe(true);
});

it('should check .package loaded', async function () {
await atom.packages.loadPackage('language-text');

const notMatch = flexToolBar.checkConditions({package: '!language-text'});
const match = flexToolBar.checkConditions({package: 'language-text'});
expect(notMatch).toBe(false);
expect(match).toBe(true);
});

it('should check .package disabled', async function () {
await atom.packages.loadPackage('language-text');
await atom.packages.disablePackage('language-text');

const notMatch = flexToolBar.checkConditions({package: 'language-text'});
const match = flexToolBar.checkConditions({package: '!language-text'});
expect(notMatch).toBe(false);
expect(match).toBe(true);
});
});

describe('function condition', function () {
Expand Down

0 comments on commit b248b1a

Please sign in to comment.