kibana/tasks/build/archives.js

40 lines
1 KiB
JavaScript
Raw Normal View History

import { execFile } from 'child_process';
import { all, fromNode } from 'bluebird';
2015-08-14 06:16:54 +02:00
export default (grunt) => {
const { config, log } = grunt;
const cwd = config.get('buildDir');
const targetDir = config.get('target');
2015-08-14 06:16:54 +02:00
async function exec(cmd, args) {
log.writeln(` > ${cmd} ${args.join(' ')}`);
await fromNode(cb => execFile(cmd, args, { cwd }, cb));
}
2015-08-14 20:53:26 +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 {
const tarArguments = ['-zchf', tarPath, buildName];
// Add a flag to handle filepaths with colons (i.e. C://...) on windows
if (/^win/.test(process.platform)) {
tarArguments.push('--force-local');
}
await exec('tar', tarArguments);
2015-08-14 06:16:54 +02:00
}
}
2015-08-14 06:16:54 +02:00
grunt.registerTask('_build:archives', function () {
grunt.file.mkdir(targetDir);
2015-08-14 06:16:54 +02:00
all(
config.get('platforms').map(async platform => await archives(platform))
2015-08-14 06:16:54 +02:00
)
.nodeify(this.async());
});
};