-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support both minCSS and minCss option keys. Fixes #34.
- Loading branch information
1 parent
9b349f1
commit c849faf
Showing
10 changed files
with
113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var isMinSrcDefinedForFile = require('./is-min-src-defined-for-file'), | ||
isOptionEnabled = require('./is-option-enabled'); | ||
|
||
module.exports.getMinCssOption = function(opts) { | ||
// support both "minCSS" and "minCss" in case of typo | ||
var minCss = opts.bundleOptions.minCSS; | ||
if (typeof minCss === 'undefined') { | ||
minCss = opts.bundleOptions.minCss; | ||
} | ||
return minCss; | ||
}; | ||
|
||
module.exports.css = function (file, opts) { | ||
return !isMinSrcDefinedForFile(file, opts.minSrcs, opts.bundleName, opts.type) && | ||
isOptionEnabled(this.getMinCssOption(opts), opts.env); | ||
}; | ||
|
||
module.exports.js = function (file, opts) { | ||
return !isMinSrcDefinedForFile(file, opts.minSrcs, opts.bundleName, opts.type) && | ||
isOptionEnabled(opts.bundleOptions.uglify, opts.env); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
var libPath = './../../lib', | ||
should = require('should'), | ||
sinon = require('sinon'), | ||
proxyquire = require('proxyquire'), | ||
File = require('vinyl'); | ||
|
||
describe('is-min-enabled', function () { | ||
|
||
describe('when option enabled', function () { | ||
|
||
var fileStub, | ||
isOptionEnabledStub, | ||
opts; | ||
|
||
beforeEach(function () { | ||
var fileStub = new File({ | ||
cwd: "/", | ||
base: "/test/", | ||
path: "/test/file", | ||
contents: new Buffer("") | ||
}); | ||
isOptionEnabledStub = sinon.stub().returns(true); | ||
opts = { | ||
bundleOptions: {} | ||
}; | ||
}); | ||
|
||
it('and min src defined should return true', function () { | ||
var isMinSrcDefinedForFileStub = sinon.stub().returns(false); | ||
var isMinEnabled = proxyquire(libPath + '/is-min-enabled', { | ||
'./is-min-src-defined-for-file': isMinSrcDefinedForFileStub, | ||
'./is-option-enabled': isOptionEnabledStub | ||
}); | ||
isMinEnabled.js(fileStub, opts).should.be.ok; | ||
isMinEnabled.css(fileStub, opts).should.be.ok; | ||
}); | ||
|
||
it('and min src NOT defined should return false', function () { | ||
var isMinSrcDefinedForFileStub = sinon.stub().returns(true); | ||
var isMinEnabled = proxyquire(libPath + '/is-min-enabled', { | ||
'./is-min-src-defined-for-file': isMinSrcDefinedForFileStub, | ||
'./is-option-enabled': isOptionEnabledStub | ||
}); | ||
isMinEnabled.js(fileStub, opts).should.be.not.ok; | ||
isMinEnabled.css(fileStub, opts).should.be.not.ok; | ||
}); | ||
|
||
}); | ||
|
||
describe('when getMinCssOption called', function () { | ||
var opts, | ||
isMinEnabled = require(libPath + '/is-min-enabled'); | ||
|
||
beforeEach(function () { | ||
opts = { | ||
bundleOptions: { | ||
} | ||
}; | ||
}); | ||
|
||
it('should return minCSS key', function () { | ||
opts.bundleOptions.minCSS = false; | ||
should(isMinEnabled.getMinCssOption(opts)).eql(false); | ||
}); | ||
|
||
it('should return minCss key', function () { | ||
opts.bundleOptions.minCss = false; | ||
should(isMinEnabled.getMinCssOption(opts)).eql(false); | ||
}); | ||
|
||
}); | ||
|
||
}); |