Skip to content

Commit

Permalink
Merge pull request quaertym#100 from saygun/fix/bower-away
Browse files Browse the repository at this point in the history
Do not verify bower packages installed via npm|yarn
  • Loading branch information
quaertym authored May 22, 2019
2 parents b910283 + 6f5b508 commit f438517
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/dependency-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,19 @@ class EmberCLIDependencyChecker {
}
}

normalizedBowerDependencies() {
const npmDependencies = this.project.dependencies();
const bowerDependencies = this.project.bowerDependencies();
Object.keys(bowerDependencies).forEach((pkg) => {
if(npmDependencies.hasOwnProperty(`@bower_components/${pkg}`)) {
delete bowerDependencies[pkg];
}
});
return bowerDependencies;
}

readBowerDependencies() {
return this.readDependencies(this.project.bowerDependencies(), 'bower');
return this.readDependencies(this.normalizedBowerDependencies(), 'bower');
}

readNPMDependencies() {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/project-bower-away/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "project-bower-away",
"dependencies": {
"ember": "1.0.0"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions tests/unit/dependency-checker-bower-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ describe('EmberCLIDependencyChecker', function() {
DependencyChecker.setAlreadyChecked(false);
});

function createProject(bowerDependencies) {
function createProject(bowerDependencies, npmDependencies = {}) {
return projectBuilder.build({
root: 'tests/fixtures/project-bower-check',
bowerDependencies: projectBuilder.buildBowerDependencies(bowerDependencies)
bowerDependencies: projectBuilder.buildBowerDependencies(bowerDependencies),
dependencies: projectBuilder.buildDependencies(npmDependencies),
});
}

Expand Down Expand Up @@ -98,5 +99,10 @@ describe('EmberCLIDependencyChecker', function() {
const project = createProject({ 'ember': '*' });
assertNoBowerError(project);
});

it('when the package is installed via yarn or npm', function() {
const project = createProject({ 'ember': '1.0.0' }, { '@bower_components/ember': '1.0.0' });
assertNoBowerError(project);
});
});
});
10 changes: 10 additions & 0 deletions tests/unit/dependency-checker-package-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ describe('EmberCLIDependencyChecker', function() {
const project = createProject({ 'example-2-tar-gz': 'http://ember-cli.com/example-2-2.0.0.tar.gz' }, { root: 'tests/fixtures/project-'+ packageManagerName + '-tar-gz-check' });
assertPackageManagerError(project);
});

it('when the specified bower package is not installed via npm', function() {
const project = createProject({ '@bower_components/foo': '0.1.1' });
assertPackageManagerError(project);
});
});

describe('does not report satisfied ' + packageManagerName + ' dependencies', function() {
Expand Down Expand Up @@ -117,6 +122,11 @@ describe('EmberCLIDependencyChecker', function() {
const project = createProject({ 'example-tar-gz': 'http://ember-cli.com/example-2.0.0.tar.gz' }, { root: 'tests/fixtures/project-'+ packageManagerName + '-tar-gz-at-check' });
assertNoPackageManagerError(project);
});

it('when the specified bower package is installed via npm', function() {
const project = createProject({ '@bower_components/ember': '1.0.0' }, { root: 'tests/fixtures/project-bower-away' });
assertNoPackageManagerError(project);
});
});

describe('sibling node_modules/ directory', function() {
Expand Down

0 comments on commit f438517

Please sign in to comment.