Skip to content

Commit ac1026e

Browse files
elwayman02Kelly Selden
authored andcommitted
Support Detection of Ember/Glimmer apps as dependencies (#524)
Support Detection of Ember/Glimmer apps as dependencies This change allows ember-cli/glimmer to be specified as either a dependency or devDependency of the project being updated. Currently, `ember-cli-update` throws an error in some instances, since it is only checking devDependencies.
1 parent 6cccf77 commit ac1026e

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

src/get-project-options.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module.exports = function getProjectOptions({
44
keywords,
5+
dependencies,
56
devDependencies
67
}) {
78
let isAddon = keywords && keywords.indexOf('ember-addon') !== -1;
@@ -10,18 +11,18 @@ module.exports = function getProjectOptions({
1011
return ['addon'];
1112
}
1213

13-
if (devDependencies) {
14-
let isGlimmer = devDependencies['@glimmer/blueprint'];
14+
let allDeps = Object.assign({}, dependencies, devDependencies);
1515

16-
if (isGlimmer) {
17-
return ['glimmer'];
18-
}
16+
let isGlimmer = allDeps['@glimmer/blueprint'];
1917

20-
let isApp = devDependencies['ember-cli'];
18+
if (isGlimmer) {
19+
return ['glimmer'];
20+
}
21+
22+
let isApp = allDeps['ember-cli'];
2123

22-
if (isApp) {
23-
return ['app'];
24-
}
24+
if (isApp) {
25+
return ['app'];
2526
}
2627

2728
throw 'Ember CLI project type could not be determined';

test/unit/get-project-options-test.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe(getProjectOptions, function() {
1313
}).to.throw('Ember CLI project type could not be determined');
1414
});
1515

16-
it('detects ember app', function() {
16+
it('detects ember app with ember-cli as a devDependency', function() {
1717
let packageJson = {
1818
devDependencies: {
1919
'ember-cli': '2.11'
@@ -23,7 +23,17 @@ describe(getProjectOptions, function() {
2323
expect(getProjectOptions(packageJson)).to.deep.equal(['app']);
2424
});
2525

26-
it('detects ember addon', function() {
26+
it('detects ember app with ember-cli as a dependency', function() {
27+
let packageJson = {
28+
dependencies: {
29+
'ember-cli': '2.11'
30+
}
31+
};
32+
33+
expect(getProjectOptions(packageJson)).to.deep.equal(['app']);
34+
});
35+
36+
it('detects ember addon with ember-cli as a devDependency', function() {
2737
let packageJson = {
2838
keywords: [
2939
'ember-addon'
@@ -36,7 +46,20 @@ describe(getProjectOptions, function() {
3646
expect(getProjectOptions(packageJson)).to.deep.equal(['addon']);
3747
});
3848

39-
it('detects glimmer app', function() {
49+
it('detects ember addon with ember-cli as a dependency', function() {
50+
let packageJson = {
51+
keywords: [
52+
'ember-addon'
53+
],
54+
dependencies: {
55+
'ember-cli': '2.11'
56+
}
57+
};
58+
59+
expect(getProjectOptions(packageJson)).to.deep.equal(['addon']);
60+
});
61+
62+
it('detects glimmer app with glimmer as a devDependency', function() {
4063
let packageJson = {
4164
devDependencies: {
4265
'@glimmer/blueprint': '0.3'
@@ -45,4 +68,14 @@ describe(getProjectOptions, function() {
4568

4669
expect(getProjectOptions(packageJson)).to.deep.equal(['glimmer']);
4770
});
71+
72+
it('detects glimmer app with glimmer as a dependency', function() {
73+
let packageJson = {
74+
dependencies: {
75+
'@glimmer/blueprint': '0.3'
76+
}
77+
};
78+
79+
expect(getProjectOptions(packageJson)).to.deep.equal(['glimmer']);
80+
});
4881
});

0 commit comments

Comments
 (0)