Skip to content

Commit

Permalink
WzIP: chore(Gruntfile) : fix to change __VERSION__ to current version
Browse files Browse the repository at this point in the history
ref e-233
  • Loading branch information
sculove committed Dec 16, 2015
1 parent 6ee4b82 commit 27591e1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 17 deletions.
14 changes: 13 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ module.exports = function(grunt) {
}
});

grunt.registerTask("cleanPkgd", function() {
if (grunt.file.exists("dist/pkgd/eg.pkgd.js")) {
grunt.file["delete"]("dist/pkgd/eg.pkgd.js", { force: true });
}
if (grunt.file.exists("dist/pkgd/flicking.pkgd.js")) {
grunt.file["delete"]("dist/pkgd/flicking.pkgd.js", { force: true });
}
if (grunt.file.exists("dist/pkgd/infiniteGrid.pkgd.js")) {
grunt.file["delete"]("dist/pkgd/infiniteGrid.pkgd.js", { force: true });
}
});

grunt.registerTask("validate-commit", function() {
if (!grunt.file.exists(".git/hooks/commit-msg")) {
var fs = require("fs");
Expand All @@ -56,7 +68,7 @@ module.exports = function(grunt) {
});

grunt.registerTask("docBuild", ["copy:doc", "clean", "jsdoc"]);
grunt.registerTask("build", ["concat", "uglify", "docBuild"]);
grunt.registerTask("build", ["concat", "uglify", "cleanPkgd", "docBuild"]);
// grunt.registerTask("build", ["concat", "uglify", "copy:lib", "docBuild"]);
grunt.registerTask("default", ["validate-commit","jshint", "jscs", "build", "test"]);
grunt.registerTask("check", ["jshint", "jscs", "test"]);
Expand Down
44 changes: 35 additions & 9 deletions config/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,44 @@ var jsonfile = require('jsonfile')
var dependency = require('./dependency')
var version = jsonfile.readFileSync("package.json").version;

function changeSrc(src) {
// remove "use strict";
// change version;
src = src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, "$1").replace(/#__VERSION__#/g, version);
return src;
}

module.exports = {
options: {
banner: "<%=banner.common %>\"use strict\";\n",
process: function(src) {
// remove "use strict";
// change version;
src = src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, "$1").replace(/#__VERSION__#/g, version);
return src;
}
},
build: {
options: {
banner: "<%=banner.common %>\"use strict\";\n",
process: changeSrc
},
src: dependency.egCore.concat(dependency.egExtend, ["src/visible.js", "src/movableCoord.js", "src/flicking.js", "src/infiniteGrid.js"]),
dest: "dist/<%=pkg.outputname%>.js"
},
pkgd_eg: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('egjs') %><%=concat.pkgd_eg.src.join('\\n* ')%>\n*/\n",
process: changeSrc
},
src : dependency.hammer.concat(dependency.outlayer, dependency.egCore, dependency.egExtend, ["src/visible.js", "src/movableCoord.js", "src/flicking.js", "src/infiniteGrid.js"]),
dest : "dist/pkgd/<%=pkg.outputname%>.pkgd.js"
},
pkgd_flicking: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('eg.flicking') %><%=concat.pkgd_flicking.src.join('\\n* ')%>\n*/\n",
process: changeSrc
},
src : dependency.hammer.concat(dependency.egCore, ["src/hook/css.js", "src/movableCoord.js", "src/flicking.js"]),
dest : "dist/pkgd/flicking.pkgd.js"
},
pkgd_infiniteGrid: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('eg.infiniteGrid') %><%=concat.pkgd_infiniteGrid.src.join('\\n* ')%>\n*/",
process: changeSrc
},
src : dependency.outlayer.concat(dependency.egCore, ["src/customEvent/scrollEnd.js", "src/plugin/persist.js", "src/infiniteGrid.js"]),
dest : "dist/pkgd/infiniteGrid.pkgd.js"
}
};
14 changes: 7 additions & 7 deletions config/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ module.exports = {
},
pkgd_eg: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('egjs') %><%=uglify.pkgd_eg.src.join('\\n* ')%>\n*/\n"
banner : "<%=banner.common %><%=banner.pkgd('egjs') %><%=concat.pkgd_eg.src.join('\\n* ')%>\n*/\n"
},
src : dependency.hammer.concat(dependency.outlayer, dependency.egCore, dependency.egExtend, ["src/visible.js", "src/movableCoord.js", "src/flicking.js", "src/infiniteGrid.js"]),
dest : "dist/pkgd/eg.pkgd.min.js"
src : "dist/pkgd/<%=pkg.outputname%>.pkgd.js",
dest : "dist/pkgd/<%=pkg.outputname%>.pkgd.min.js"
},
pkgd_flicking: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('eg.flicking') %><%=uglify.pkgd_flicking.src.join('\\n* ')%>\n*/\n"
banner : "<%=banner.common %><%=banner.pkgd('eg.flicking') %><%=concat.pkgd_flicking.src.join('\\n* ')%>\n*/\n"
},
src : dependency.hammer.concat(dependency.egCore, ["src/hook/css.js", "src/movableCoord.js", "src/flicking.js"]),
src : "dist/pkgd/flicking.pkgd.js",
dest : "dist/pkgd/flicking.pkgd.min.js"
},
pkgd_infiniteGrid: {
options : {
banner : "<%=banner.common %><%=banner.pkgd('eg.infiniteGrid') %><%=uglify.pkgd_infiniteGrid.src.join('\\n* ')%>\n*/\n"
banner : "<%=banner.common %><%=banner.pkgd('eg.infiniteGrid') %><%=concat.pkgd_infiniteGrid.src.join('\\n* ')%>\n*/\n"
},
src : dependency.outlayer.concat(dependency.egCore, ["src/customEvent/scrollEnd.js", "src/plugin/persist.js", "src/infiniteGrid.js"]),
src : "dist/pkgd/infiniteGrid.pkgd.js",
dest : "dist/pkgd/infiniteGrid.pkgd.min.js"
}
};

0 comments on commit 27591e1

Please sign in to comment.