mirror of
https://github.com/wassname/mad.git
synced 2026-06-27 16:10:31 +08:00
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
module.exports = function( grunt ) {
|
|
'use strict';
|
|
|
|
grunt.loadNpmTasks('grunt-crx');
|
|
grunt.loadNpmTasks('grunt-contrib-compress');
|
|
|
|
var config = {
|
|
app: 'src',
|
|
dist: 'dist',
|
|
package: grunt.file.readJSON('package.json')
|
|
};
|
|
|
|
grunt.initConfig({
|
|
config: config,
|
|
crx: {
|
|
testPackage: {
|
|
"src": "<%= config.app %>",
|
|
"dest": "<%= config.dist %>/crx/",
|
|
"zipDest": "<%= config.dist %>/<%= config.package.name %>-<%= config.package.version %>.zip",
|
|
"privateKey": "<%= config.dist %>/mad.pem"
|
|
},
|
|
},
|
|
compress: {
|
|
dist:{
|
|
options: {
|
|
archive: '<%= config.dist %>/<%= config.package.name %>-<%= config.package.version %>.zip'
|
|
},
|
|
files: [{
|
|
expand: true,
|
|
cwd: '<%= config.app %>/',
|
|
src: ['**'],
|
|
dest: ''
|
|
}]
|
|
}
|
|
}
|
|
});
|
|
grunt.registerTask('updatejson', function (key, value) {
|
|
var projectFile = "src/manifest.json";
|
|
|
|
if (!grunt.file.exists(projectFile)) {
|
|
grunt.log.error("file " + projectFile + " not found");
|
|
return true;//return false to abort the execution
|
|
}
|
|
var project = grunt.file.readJSON(projectFile);//get file as json object
|
|
|
|
project['version']= config.package.version;//edit the value of json object, you can also use projec.key if you know what you are updating
|
|
|
|
grunt.file.write(projectFile, JSON.stringify(project, null, 2));//serialize it back to file
|
|
|
|
});
|
|
grunt.registerTask('default', ['crx', 'compress', 'updatejson']
|
|
);
|
|
|
|
};
|