Navigation Menu

Skip to content

Commit

Permalink
fix replace removals in universal builder
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Feb 27, 2015
1 parent 74847dd commit cd9f5d4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/build.js
Expand Up @@ -71,7 +71,7 @@ function build(generate, generateBanner, pkg) {
output = banner + output;

// Remove `define('modernizr-init' ...)` and `define('modernizr-build' ...)`
output = output.replace(/define\("modernizr-(init|build)", function\(\)\{\}\);/g, '');
output = output.replace(/define\("modernizr-(init|build)",\s*function\(\)\{\};?\)/g, '');
output = output.replace(/__VERSION__/g, pkg.version);

// Hack the prefix into place. Anything is way too big for something so small.
Expand Down
72 changes: 72 additions & 0 deletions test/node/lib/build.js
Expand Up @@ -58,6 +58,78 @@ describe('cli/build', function() {
done();
});
});

describe('unminified', function() {
var output;

before(function(done) {
var config = {
'feature-detects': ['css/boxsizing']
};

build(config, function(file) {
output = file;
done();
});
});

it('strips out the modernizr-init/build `define` section', function() {
var defineRe = /define\("modernizr-(init|build)"\)/m;
expect(defineRe.test(output)).to.be(false);
});

it('strips out the `define` section', function() {
var docRe = /define\(.*?\{/;
expect(docRe.test(output)).to.be(false);
});

it('strips out the `require` section', function() {
var requireRe = /require[^\{\r\n]+\{/;
expect(requireRe.test(output)).to.be(false);
});

it('replaces __VERSION__ ', function() {
expect(output).to.not.contain('__VERSION__');
});

});

describe('minified', function() {
var output;

before(function(done) {
var config = {
'feature-detects': ['css/boxsizing'],
minify: true
};

build(config, function(file) {
output = file;
done();
});
});

it('strips out the modernizr-init/build `define` section', function() {
var defineRe = /define\("modernizr-(init|build)"\)/m;
expect(defineRe.test(output)).to.be(false);
});

it('strips out the `define` section', function() {
var docRe = /define\(.*?\{/;
expect(docRe.test(output)).to.be(false);
});

it('strips out the `require` section', function() {
var requireRe = /require[^\{\r\n]+\{/;
expect(requireRe.test(output)).to.be(false);
});

it('replaces __VERSION__ ', function() {
expect(output).to.not.contain('__VERSION__');
});

});

});

});

0 comments on commit cd9f5d4

Please sign in to comment.