Skip to content

Commit

Permalink
cleanup for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
SlexAxton committed Dec 5, 2012
1 parent eed5e0c commit ff031ef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
2 changes: 0 additions & 2 deletions bin/modernizr
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash
node ./lib/generate-init.js $1
grunt build > /dev/null
rm -rf ./tmp
cat ./dist/modernizr-build.js
55 changes: 28 additions & 27 deletions grunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,39 +125,40 @@ module.exports = function( grunt ) {
//Remove AMD ceremony for use without require.js or almond.js
contents = contents.replace(/define\(.*?\{/, '');

contents = contents.replace(/\}\);\s*?$/,'');
contents = contents.replace(/\}\);\s*?$/,'');

if ( !contents.match(/Modernizr\.addTest\(/) && !contents.match(/Modernizr\.addAsyncTest\(/) ) {
//remove last return statement and trailing })
contents = contents.replace(/return.*[^return]*$/,'');
}
if ( !contents.match(/Modernizr\.addTest\(/) && !contents.match(/Modernizr\.addAsyncTest\(/) ) {
//remove last return statement and trailing })
contents = contents.replace(/return.*[^return]*$/,'');
}
}
else if ((/require\([^\{]*?\{/).test(contents)) {
contents = contents.replace(/require[^\{]+\{/, '');
contents = contents.replace(/\}\);\s*$/,'');
}
return contents;
}
}
contents = contents.replace(/\}\);\s*$/,'');
}
}
});

// Strip define fn
grunt.registerMultiTask('stripdefine', "Strip define call from dist file", function() {
var mod = grunt.file.read( this.file.src[0] ).replace('define("modernizr-init",[], function(){});', '');
grunt.file.write( 'dist/modernizr-build.js', mod );
});
return contents;
}
}
}
}
});

// Strip define fn
grunt.registerMultiTask('stripdefine', "Strip define call from dist file", function() {
var mod = grunt.file.read( this.file.src[0] ).replace('define("modernizr-init",[], function(){});', '');
grunt.file.write( 'dist/modernizr-build.js', mod );
});

grunt.registerMultiTask('generateinit', "Generate Init file", function() {
grunt.file.write('tmp/modernizr-init.js', generateInit(JSON.parse(grunt.file.read('config-all.json'))));
});
grunt.registerMultiTask('generateinit', "Generate Init file", function() {
grunt.file.write('tmp/modernizr-init.js', generateInit(JSON.parse(grunt.file.read('config-all.json'))));
});

// Travis CI task.
grunt.registerTask('travis', 'qunit');
// Travis CI task.
grunt.registerTask('travis', 'qunit');

// Build
grunt.loadNpmTasks('grunt-contrib');
grunt.registerTask('build', 'clean generateinit requirejs copy clean:postbuild stripdefine min');
grunt.registerTask('default', 'build');
};
// Build
grunt.loadNpmTasks('grunt-contrib');
grunt.registerTask('build', 'clean generateinit requirejs copy clean:postbuild stripdefine min');
grunt.registerTask('default', 'build');
};
6 changes: 4 additions & 2 deletions modular.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
<body>
<div>
<h1>Config JSON</h1>
<textarea id="config-json">{
<textarea id="config-json">{
"options": [
"setClasses",
"addTest",
"html5printshiv",
"load"
"load",
"testProp",
"fnBind"
],
"feature-detects": [
"test/a/download",
Expand Down

0 comments on commit ff031ef

Please sign in to comment.