Skip to content

Commit db51b4b

Browse files
authored
Merge pull request #124 from gnclmorais/master
Skip dependency check on `ember init`
2 parents 933bb89 + 6684d18 commit db51b4b

File tree

6 files changed

+169
-9
lines changed

6 files changed

+169
-9
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
language: node_js
33
node_js:
4-
- "6"
54
- "8"
65
- "10"
76

appveyor.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ init:
77
# Test against these versions of Node.js.
88
environment:
99
matrix:
10-
- nodejs_version: "6"
1110
- nodejs_version: "8"
1211
- nodejs_version: "10"
12+
image:
13+
- Ubuntu
14+
- Visual Studio 2017
1315

1416
# Install scripts. (runs after repo cloning)
1517
install:
16-
- ps: Install-Product node $env:nodejs_version
17-
- appveyor-retry yarn --frozen-lockfile --non-interactive
18+
- cmd: powershell Install-Product node $env:nodejs_version
19+
- sh: nvm install $nodejs_version
20+
- yarn --frozen-lockfile --non-interactive
1821

1922
cache:
2023
- '%LOCALAPPDATA%\Yarn'

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ module.exports = {
88
init: function() {
99
this._super.init && this._super.init.apply(this, arguments);
1010

11-
const reporter = new Reporter();
12-
const dependencyChecker = new DependencyChecker(this.project, reporter);
13-
dependencyChecker.checkDependencies();
11+
// When running `ember <command>`, find the `<command>`
12+
const emberPosition = process.argv.findIndex(arg => arg.endsWith('/ember'));
13+
const ranWithInit = process.argv[emberPosition + 1] === 'init';
14+
15+
if (ranWithInit) {
16+
process.emitWarning('Skipped dependency checker…');
17+
} else {
18+
const reporter = new Reporter();
19+
const dependencyChecker = new DependencyChecker(this.project, reporter);
20+
dependencyChecker.checkDependencies();
21+
}
1422
}
1523
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"glob": "^7.1.1",
5151
"mocha": "^5.2.0",
5252
"mocha-eslint": "^4.1.0",
53-
"qunit-dom": "^0.7.0"
53+
"qunit-dom": "^0.7.0",
54+
"sinon": "^13.0.0"
5455
},
5556
"peerDependencies": {
5657
"ember-cli": "~3.2.0"

tests/unit/index-test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* eslint-env node, mocha */
2+
const assert = require('chai').assert;
3+
const sinon = require('sinon');
4+
const index = require('../../index');
5+
const DependencyChecker = require('../../lib/dependency-checker');
6+
7+
// Simple stubbing of some basic inner workings of the module
8+
const indexStub = {
9+
_super: { init: () => {} },
10+
...index,
11+
}
12+
13+
describe('index', function () {
14+
let argv;
15+
16+
beforeEach(function() {
17+
// Keep a reference to the original arguments,
18+
// since we're going to fiddle with them.
19+
argv = process.argv;
20+
});
21+
22+
afterEach(function() {
23+
// Restore the original arguments and any changes made through sinon.
24+
process.argv = argv;
25+
sinon.restore();
26+
});
27+
28+
describe('command passed to ember is init', function () {
29+
it('does not check dependencies', function () {
30+
// Arrange
31+
const dependenciesChecked = sinon.stub(DependencyChecker.prototype, 'checkDependencies');
32+
const extraArgs = ['/path/to/ember', 'init', 'something-else'];
33+
process.argv = [...process.argv, ...extraArgs];
34+
35+
// Act
36+
indexStub.init();
37+
38+
// Assert
39+
assert.isFalse(dependenciesChecked.called, 'Dependencies have not been checked');
40+
});
41+
});
42+
43+
describe('command passed to ember is not init', function () {
44+
it('checks dependencies', function () {
45+
// Arrange
46+
const dependenciesChecked = sinon.stub(DependencyChecker.prototype, 'checkDependencies');
47+
const extraArgs = ['/path/to/ember', 'link', 'something-else'];
48+
process.argv = [...process.argv, ...extraArgs];
49+
50+
// Act
51+
indexStub.init();
52+
53+
// Assert
54+
assert.isTrue(dependenciesChecked.called, 'Dependencies have not been checked');
55+
});
56+
});
57+
});

yarn.lock

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,41 @@
66
version "0.7.0"
77
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"
88

9+
"@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3":
10+
version "1.8.3"
11+
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
12+
integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==
13+
dependencies:
14+
type-detect "4.0.8"
15+
16+
"@sinonjs/fake-timers@^7.0.4":
17+
version "7.1.2"
18+
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz#2524eae70c4910edccf99b2f4e6efc5894aff7b5"
19+
integrity sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==
20+
dependencies:
21+
"@sinonjs/commons" "^1.7.0"
22+
23+
"@sinonjs/fake-timers@^9.0.0":
24+
version "9.0.0"
25+
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-9.0.0.tgz#6854809cd058c6e25b3da2fa063153eaea4ffc72"
26+
integrity sha512-+shXA2X7KNP7H7qNbQTJ3SA+NQc0pZDSBrdvFSRwF8sAo/ohw+ZQFD8Moc+gnz51+1eRXtEQBpKWPiQ4jsRC/w==
27+
dependencies:
28+
"@sinonjs/commons" "^1.7.0"
29+
30+
"@sinonjs/samsam@^6.1.1":
31+
version "6.1.1"
32+
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-6.1.1.tgz#627f7f4cbdb56e6419fa2c1a3e4751ce4f6a00b1"
33+
integrity sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==
34+
dependencies:
35+
"@sinonjs/commons" "^1.6.0"
36+
lodash.get "^4.4.2"
37+
type-detect "^4.0.8"
38+
39+
"@sinonjs/text-encoding@^0.7.1":
40+
version "0.7.1"
41+
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
42+
integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==
43+
944
abbrev@1:
1045
version "1.1.1"
1146
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
@@ -1626,6 +1661,11 @@ [email protected], diff@^3.2.0:
16261661
version "3.5.0"
16271662
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
16281663

1664+
diff@^5.0.0:
1665+
version "5.0.0"
1666+
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
1667+
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
1668+
16291669
doctrine@^2.1.0:
16301670
version "2.1.0"
16311671
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
@@ -2564,6 +2604,11 @@ has-flag@^3.0.0:
25642604
version "3.0.0"
25652605
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
25662606

2607+
has-flag@^4.0.0:
2608+
version "4.0.0"
2609+
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
2610+
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
2611+
25672612
has-symbol-support-x@^1.4.1:
25682613
version "1.4.2"
25692614
resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455"
@@ -3069,6 +3114,11 @@ jsonify@~0.0.0:
30693114
version "0.0.0"
30703115
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
30713116

3117+
just-extend@^4.0.2:
3118+
version "4.2.1"
3119+
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.2.1.tgz#ef5e589afb61e5d66b24eca749409a8939a8c744"
3120+
integrity sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==
3121+
30723122
30733123
version "3.0.0"
30743124
resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.0.0.tgz#44923ba39e68b12a7cec7df6c3268c031f2ef373"
@@ -3352,6 +3402,11 @@ lodash.forown@~2.3.0:
33523402
lodash._objecttypes "~2.3.0"
33533403
lodash.keys "~2.3.0"
33543404

3405+
lodash.get@^4.4.2:
3406+
version "4.4.2"
3407+
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
3408+
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
3409+
33553410
lodash.identity@~2.3.0:
33563411
version "2.3.0"
33573412
resolved "https://registry.yarnpkg.com/lodash.identity/-/lodash.identity-2.3.0.tgz#6b01a210c9485355c2a913b48b6711219a173ded"
@@ -3809,6 +3864,17 @@ nice-try@^1.0.4:
38093864
version "1.0.4"
38103865
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
38113866

3867+
nise@^5.1.0:
3868+
version "5.1.0"
3869+
resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.0.tgz#713ef3ed138252daef20ec035ab62b7a28be645c"
3870+
integrity sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ==
3871+
dependencies:
3872+
"@sinonjs/commons" "^1.7.0"
3873+
"@sinonjs/fake-timers" "^7.0.4"
3874+
"@sinonjs/text-encoding" "^0.7.1"
3875+
just-extend "^4.0.2"
3876+
path-to-regexp "^1.7.0"
3877+
38123878
no-case@^2.2.0:
38133879
version "2.3.2"
38143880
resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"
@@ -4131,6 +4197,13 @@ [email protected]:
41314197
version "0.1.7"
41324198
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
41334199

4200+
path-to-regexp@^1.7.0:
4201+
version "1.8.0"
4202+
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
4203+
integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
4204+
dependencies:
4205+
isarray "0.0.1"
4206+
41344207
path-type@^1.0.0:
41354208
version "1.1.0"
41364209
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
@@ -4633,6 +4706,18 @@ silent-error@^1.0.0, silent-error@^1.0.1, silent-error@^1.1.0:
46334706
dependencies:
46344707
debug "^2.2.0"
46354708

4709+
sinon@^13.0.0:
4710+
version "13.0.0"
4711+
resolved "https://registry.yarnpkg.com/sinon/-/sinon-13.0.0.tgz#3701f90204a1baa7457a3da70c9adcf335e92056"
4712+
integrity sha512-3tjMDB/tY04b06Bnb4aMKQfNrau2C9HET+R4HVWfv2KegDVLGg4wnBqjVepvxR7S7R1GTwDZzEv52tpFipt6yA==
4713+
dependencies:
4714+
"@sinonjs/commons" "^1.8.3"
4715+
"@sinonjs/fake-timers" "^9.0.0"
4716+
"@sinonjs/samsam" "^6.1.1"
4717+
diff "^5.0.0"
4718+
nise "^5.1.0"
4719+
supports-color "^7.2.0"
4720+
46364721
slash@^1.0.0:
46374722
version "1.0.0"
46384723
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
@@ -4931,6 +5016,13 @@ supports-color@^2.0.0:
49315016
version "2.0.0"
49325017
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
49335018

5019+
supports-color@^7.2.0:
5020+
version "7.2.0"
5021+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
5022+
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
5023+
dependencies:
5024+
has-flag "^4.0.0"
5025+
49345026
symlink-or-copy@^1.0.0, symlink-or-copy@^1.0.1, symlink-or-copy@^1.1.8, symlink-or-copy@^1.2.0:
49355027
version "1.2.0"
49365028
resolved "https://registry.yarnpkg.com/symlink-or-copy/-/symlink-or-copy-1.2.0.tgz#5d49108e2ab824a34069b68974486c290020b393"
@@ -5108,7 +5200,7 @@ type-check@~0.3.2:
51085200
dependencies:
51095201
prelude-ls "~1.1.2"
51105202

5111-
type-detect@^4.0.0:
5203+
type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.8:
51125204
version "4.0.8"
51135205
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
51145206

0 commit comments

Comments
 (0)