2013-08-22 06:35:47 +00:00
|
|
|
module.exports = function(grunt) {
|
2013-09-11 21:17:27 +00:00
|
|
|
|
|
|
|
var exec = require("child_process").exec;
|
|
|
|
var path = require("path");
|
|
|
|
var fs = require("fs");
|
2013-08-22 06:35:47 +00:00
|
|
|
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-less");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
2013-09-06 16:28:41 +00:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
2013-09-11 21:17:27 +00:00
|
|
|
grunt.loadNpmTasks("grunt-contrib-copy");
|
2013-08-22 06:35:47 +00:00
|
|
|
|
|
|
|
grunt.initConfig({
|
|
|
|
less: {
|
2013-09-13 22:57:57 +00:00
|
|
|
light: {
|
2013-08-22 06:35:47 +00:00
|
|
|
files: {
|
2013-09-13 22:57:57 +00:00
|
|
|
"css/caret.css": "css/seed.less",
|
|
|
|
"css/caret-dark.css": "css/seed-dark.less"
|
2013-08-22 06:35:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
css: {
|
|
|
|
files: ["css/*.less"],
|
|
|
|
tasks: ["less"]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
spawn: false
|
|
|
|
}
|
2013-09-06 16:28:41 +00:00
|
|
|
},
|
|
|
|
compress: {
|
2013-09-10 16:19:14 +00:00
|
|
|
pack: {
|
2013-09-06 16:28:41 +00:00
|
|
|
options: {
|
|
|
|
archive: "build/caret.zip",
|
|
|
|
pretty: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
"/": ["config/**", "js/**", "css/*.css", "*.html", "manifest.json", "require.js", "background.js", "*.png"]
|
|
|
|
}
|
|
|
|
}
|
2013-09-11 21:17:27 +00:00
|
|
|
},
|
|
|
|
copy: {
|
|
|
|
unpacked: {
|
|
|
|
dest: "build/unpacked/",
|
|
|
|
src: ["config/**", "js/**", "css/*.css", "*.html", "manifest.json", "require.js", "background.js", "*.png"]
|
|
|
|
}
|
2013-08-22 06:35:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.registerTask("default", ["less", "watch"]);
|
2013-09-13 22:57:57 +00:00
|
|
|
grunt.registerTask("package", ["less", "compress:pack", "copy:unpacked", "crx"]);
|
2013-09-11 21:17:27 +00:00
|
|
|
|
|
|
|
grunt.registerTask("crx", "Makes a new CRX package", function() {
|
2013-09-12 06:29:04 +00:00
|
|
|
var manifest = JSON.parse(fs.readFileSync("./build/unpacked/manifest.json"));
|
|
|
|
manifest.icons["128"] = "icon-128-inverted.png";
|
|
|
|
fs.writeFileSync("./build/unpacked/manifest.json", JSON.stringify(manifest, null, 2));
|
|
|
|
|
|
|
|
//perform the Chrome packaging
|
2013-09-11 21:17:27 +00:00
|
|
|
var c = this.async();
|
|
|
|
var here = fs.realpathSync(__dirname);
|
2013-09-12 16:58:31 +00:00
|
|
|
|
|
|
|
var chrome = {
|
2013-09-12 18:52:49 +00:00
|
|
|
win32: '"' + (process.env["ProgramFiles(x86)"] || process.env.ProgramFiles) + "\\Google\\Chrome\\Application\\chrome.exe" + '"',
|
2013-09-13 16:14:46 +00:00
|
|
|
linux: "/opt/google/chrome/chrome",
|
|
|
|
osx: "Beats me."
|
2013-09-12 16:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var cmd = [ chrome[process.platform] ];
|
2013-09-11 21:17:27 +00:00
|
|
|
cmd.push("--pack-extension=" + path.join(here, "build/unpacked"));
|
|
|
|
cmd.push("--pack-extension-key=" + path.join(here, "../Caret.pem"));
|
|
|
|
exec(cmd.join(" "),function(err, out, stderr) {
|
2013-09-12 16:58:31 +00:00
|
|
|
if (err) {
|
|
|
|
console.log(stderr);
|
|
|
|
}
|
2013-09-11 21:17:27 +00:00
|
|
|
fs.renameSync("./build/unpacked.crx", "./build/Caret.crx");
|
|
|
|
exec("rm -rf ./build/unpacked");
|
|
|
|
c();
|
|
|
|
});
|
|
|
|
});
|
2013-08-22 06:35:47 +00:00
|
|
|
|
2013-09-11 14:59:13 +00:00
|
|
|
};
|