2016-06-17 15:39:14 +02:00
|
|
|
import { execFile } from 'child_process';
|
|
|
|
import { all, fromNode } from 'bluebird';
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2016-06-17 15:39:14 +02:00
|
|
|
export default (grunt) => {
|
|
|
|
const { config, log } = grunt;
|
|
|
|
|
|
|
|
const cwd = config.get('buildDir');
|
2016-06-16 16:36:06 +02:00
|
|
|
const targetDir = config.get('target');
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2016-06-17 15:39:14 +02:00
|
|
|
async function exec(cmd, args) {
|
|
|
|
log.writeln(` > ${cmd} ${args.join(' ')}`);
|
|
|
|
await fromNode(cb => execFile(cmd, args, { cwd }, cb));
|
2016-12-14 02:17:47 +01:00
|
|
|
}
|
2015-08-14 20:53:26 +02:00
|
|
|
|
2016-06-17 15:39:14 +02:00
|
|
|
async function archives({ name, buildName, zipPath, tarPath }) {
|
|
|
|
if (/windows/.test(name)) {
|
|
|
|
await exec('zip', ['-rq', '-ll', zipPath, buildName]);
|
2015-08-14 06:16:54 +02:00
|
|
|
} else {
|
2016-06-17 15:39:14 +02:00
|
|
|
await exec('tar', ['-zchf', tarPath, buildName]);
|
2015-08-14 06:16:54 +02:00
|
|
|
}
|
2016-12-14 02:17:47 +01:00
|
|
|
}
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2015-08-14 22:27:41 +02:00
|
|
|
grunt.registerTask('_build:archives', function () {
|
2016-06-17 15:39:14 +02:00
|
|
|
grunt.file.mkdir(targetDir);
|
2015-08-14 06:16:54 +02:00
|
|
|
|
|
|
|
all(
|
2016-06-17 15:39:14 +02:00
|
|
|
config.get('platforms').map(async platform => await archives(platform))
|
2015-08-14 06:16:54 +02:00
|
|
|
)
|
|
|
|
.nodeify(this.async());
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|