Skip to content

Commit

Permalink
Merge pull request #124 from gnclmorais/master
Browse files Browse the repository at this point in the history
Skip dependency check on `ember init`
  • Loading branch information
quaertym authored Feb 18, 2022
2 parents 933bb89 + 6684d18 commit db51b4b
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 9 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
language: node_js
node_js:
- "6"
- "8"
- "10"

Expand Down
9 changes: 6 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ init:
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
image:
- Ubuntu
- Visual Studio 2017

# Install scripts. (runs after repo cloning)
install:
- ps: Install-Product node $env:nodejs_version
- appveyor-retry yarn --frozen-lockfile --non-interactive
- cmd: powershell Install-Product node $env:nodejs_version
- sh: nvm install $nodejs_version
- yarn --frozen-lockfile --non-interactive

cache:
- '%LOCALAPPDATA%\Yarn'
Expand Down
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ module.exports = {
init: function() {
this._super.init && this._super.init.apply(this, arguments);

const reporter = new Reporter();
const dependencyChecker = new DependencyChecker(this.project, reporter);
dependencyChecker.checkDependencies();
// When running `ember <command>`, find the `<command>`
const emberPosition = process.argv.findIndex(arg => arg.endsWith('/ember'));
const ranWithInit = process.argv[emberPosition + 1] === 'init';

if (ranWithInit) {
process.emitWarning('Skipped dependency checker…');
} else {
const reporter = new Reporter();
const dependencyChecker = new DependencyChecker(this.project, reporter);
dependencyChecker.checkDependencies();
}
}
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"glob": "^7.1.1",
"mocha": "^5.2.0",
"mocha-eslint": "^4.1.0",
"qunit-dom": "^0.7.0"
"qunit-dom": "^0.7.0",
"sinon": "^13.0.0"
},
"peerDependencies": {
"ember-cli": "~3.2.0"
Expand Down
57 changes: 57 additions & 0 deletions tests/unit/index-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-env node, mocha */
const assert = require('chai').assert;
const sinon = require('sinon');
const index = require('../../index');
const DependencyChecker = require('../../lib/dependency-checker');

// Simple stubbing of some basic inner workings of the module
const indexStub = {
_super: { init: () => {} },
...index,
}

describe('index', function () {
let argv;

beforeEach(function() {
// Keep a reference to the original arguments,
// since we're going to fiddle with them.
argv = process.argv;
});

afterEach(function() {
// Restore the original arguments and any changes made through sinon.
process.argv = argv;
sinon.restore();
});

describe('command passed to ember is init', function () {
it('does not check dependencies', function () {
// Arrange
const dependenciesChecked = sinon.stub(DependencyChecker.prototype, 'checkDependencies');
const extraArgs = ['/path/to/ember', 'init', 'something-else'];
process.argv = [...process.argv, ...extraArgs];

// Act
indexStub.init();

// Assert
assert.isFalse(dependenciesChecked.called, 'Dependencies have not been checked');
});
});

describe('command passed to ember is not init', function () {
it('checks dependencies', function () {
// Arrange
const dependenciesChecked = sinon.stub(DependencyChecker.prototype, 'checkDependencies');
const extraArgs = ['/path/to/ember', 'link', 'something-else'];
process.argv = [...process.argv, ...extraArgs];

// Act
indexStub.init();

// Assert
assert.isTrue(dependenciesChecked.called, 'Dependencies have not been checked');
});
});
});
94 changes: 93 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@
version "0.7.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd"

"@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==
dependencies:
type-detect "4.0.8"

"@sinonjs/fake-timers@^7.0.4":
version "7.1.2"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz#2524eae70c4910edccf99b2f4e6efc5894aff7b5"
integrity sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==
dependencies:
"@sinonjs/commons" "^1.7.0"

"@sinonjs/fake-timers@^9.0.0":
version "9.0.0"
resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-9.0.0.tgz#6854809cd058c6e25b3da2fa063153eaea4ffc72"
integrity sha512-+shXA2X7KNP7H7qNbQTJ3SA+NQc0pZDSBrdvFSRwF8sAo/ohw+ZQFD8Moc+gnz51+1eRXtEQBpKWPiQ4jsRC/w==
dependencies:
"@sinonjs/commons" "^1.7.0"

"@sinonjs/samsam@^6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-6.1.1.tgz#627f7f4cbdb56e6419fa2c1a3e4751ce4f6a00b1"
integrity sha512-cZ7rKJTLiE7u7Wi/v9Hc2fs3Ucc3jrWeMgPHbbTCeVAB2S0wOBbYlkJVeNSL04i7fdhT8wIbDq1zhC/PXTD2SA==
dependencies:
"@sinonjs/commons" "^1.6.0"
lodash.get "^4.4.2"
type-detect "^4.0.8"

"@sinonjs/text-encoding@^0.7.1":
version "0.7.1"
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==

abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
Expand Down Expand Up @@ -1626,6 +1661,11 @@ diff@3.5.0, diff@^3.2.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"

diff@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==

doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
Expand Down Expand Up @@ -2564,6 +2604,11 @@ has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"

has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==

has-symbol-support-x@^1.4.1:
version "1.4.2"
resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455"
Expand Down Expand Up @@ -3069,6 +3114,11 @@ jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"

just-extend@^4.0.2:
version "4.2.1"
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.2.1.tgz#ef5e589afb61e5d66b24eca749409a8939a8c744"
integrity sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==

keyv@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.0.0.tgz#44923ba39e68b12a7cec7df6c3268c031f2ef373"
Expand Down Expand Up @@ -3352,6 +3402,11 @@ lodash.forown@~2.3.0:
lodash._objecttypes "~2.3.0"
lodash.keys "~2.3.0"

lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=

lodash.identity@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/lodash.identity/-/lodash.identity-2.3.0.tgz#6b01a210c9485355c2a913b48b6711219a173ded"
Expand Down Expand Up @@ -3809,6 +3864,17 @@ nice-try@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"

nise@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.0.tgz#713ef3ed138252daef20ec035ab62b7a28be645c"
integrity sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ==
dependencies:
"@sinonjs/commons" "^1.7.0"
"@sinonjs/fake-timers" "^7.0.4"
"@sinonjs/text-encoding" "^0.7.1"
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

no-case@^2.2.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"
Expand Down Expand Up @@ -4131,6 +4197,13 @@ path-to-regexp@0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"

path-to-regexp@^1.7.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
dependencies:
isarray "0.0.1"

path-type@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
Expand Down Expand Up @@ -4633,6 +4706,18 @@ silent-error@^1.0.0, silent-error@^1.0.1, silent-error@^1.1.0:
dependencies:
debug "^2.2.0"

sinon@^13.0.0:
version "13.0.0"
resolved "https://registry.yarnpkg.com/sinon/-/sinon-13.0.0.tgz#3701f90204a1baa7457a3da70c9adcf335e92056"
integrity sha512-3tjMDB/tY04b06Bnb4aMKQfNrau2C9HET+R4HVWfv2KegDVLGg4wnBqjVepvxR7S7R1GTwDZzEv52tpFipt6yA==
dependencies:
"@sinonjs/commons" "^1.8.3"
"@sinonjs/fake-timers" "^9.0.0"
"@sinonjs/samsam" "^6.1.1"
diff "^5.0.0"
nise "^5.1.0"
supports-color "^7.2.0"

slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
Expand Down Expand Up @@ -4931,6 +5016,13 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"

supports-color@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"

symlink-or-copy@^1.0.0, symlink-or-copy@^1.0.1, symlink-or-copy@^1.1.8, symlink-or-copy@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symlink-or-copy/-/symlink-or-copy-1.2.0.tgz#5d49108e2ab824a34069b68974486c290020b393"
Expand Down Expand Up @@ -5108,7 +5200,7 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"

type-detect@^4.0.0:
type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"

Expand Down

0 comments on commit db51b4b

Please sign in to comment.