ура, не много разобрался в гранте)
вот что получилось)
var path = require("path"),
fs = require("fs");
module.exports = function(grunt) {
"use strict"
var ignoredFolders = [".idea", "files"],
ignoredFormats = [".nw", ".zip", ".exe"];
grunt.initConfig({
compress: {
main: {
options: {
archive: 'app.zip'
},
files: [
{src: ['**'], filter: filter}// includes files in path
]
}
}
});
function filter (src) {
try {
var extn = path.extname(src),
folder = src.split(path.sep)[0];
return extn && ignoredFormats.indexOf(extn) == -1 &&
ignoredFolders.indexOf(folder) == -1;
}
catch (e) {
console.log(e);
}
};
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.registerTask('callback', function(){
if(!fs.existsSync("app.zip"))
return;
fs.renameSync("app.zip", "app.nw");
var exec = require('child_process').exec;
exec('app.nw', function callback(err, stdout, stderr){
if(err)
console.error(err);
});
});
grunt.registerTask('default', ['compress', 'callback']);
};