forked from imgix-wordpress/images-via-imgix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
36 lines (29 loc) · 888 Bytes
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module.exports = function(grunt) {
var exec = require('child_process').exec,
fs = require('fs');
function execRun(cmd, done) {
exec(cmd, function(err, stdout, stderr) {
if (err) {
grunt.fail.fatal(stderr + ' ' + stdout + ' ' + err);
}
if (done) {
done();
}
});
}
grunt.registerTask('buildzip', 'create a zip file for wordpress...', function() {
var zips = fs.readdirSync('.'),
content = fs.readFileSync('plugin/imgix.php', 'UTF-8'),
version = content.match(/Version: (.+)/)[1];
for (var i = 0; i < zips.length; i++) {
if (zips[i].indexOf('.zip') !== -1) {
grunt.file.delete(zips[i]);
}
}
var zipFile = "imgix_plugin-" + version + ".zip";
execRun('cp -pRv plugin imgix-wordpress/');
execRun('zip -r ' + zipFile + ' imgix-wordpress/');
execRun('rm -rf imgix-wordpress');
});
grunt.registerTask('default', 'buildzip');
};