Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
Make jQuery optional if there's no Bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
silvenon committed Jul 4, 2015
1 parent b85d700 commit 6211734
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ module.exports = generators.Base.extend({
value: 'includeModernizr',
checked: true
}]
}, {
type: 'confirm',
name: 'includeJQuery',
message: 'Would you like to include jQuery?',
default: true,
when: function (answers) {
return answers.features.indexOf('includeBootstrap') === -1;
}
}];

this.prompt(prompts, function (answers) {
Expand All @@ -90,6 +98,7 @@ module.exports = generators.Base.extend({
this.includeSass = hasFeature('includeSass');
this.includeBootstrap = hasFeature('includeBootstrap');
this.includeModernizr = hasFeature('includeModernizr');
this.includeJQuery = answers.includeJQuery;

done();
}.bind(this));
Expand Down Expand Up @@ -171,7 +180,7 @@ module.exports = generators.Base.extend({
}
};
}
} else {
} else if (this.includeJQuery) {
bowerJson.dependencies['jquery'] = '~2.1.4';
}

Expand Down
40 changes: 40 additions & 0 deletions test/jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('jquery', function () {
describe('on', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({
features: [],
includeJQuery: true
})
.on('end', done);
});

it('adds the bower dependency', function () {
assert.fileContent('bower.json', '"jquery"');
});
});

describe('off', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, 'temp'))
.withOptions({'skip-install': true})
.withPrompts({
features: [],
includeJQuery: false
})
.on('end', done);
});

it('doesn\'t add the bower dependency', function () {
assert.noFileContent('bower.json', '"jquery"');
});
});
});

0 comments on commit 6211734

Please sign in to comment.