kibana/tasks/build/archives.js
Spencer 98a1c5a0f1
[6.x] Upgrade to eslint 4 (#14862) (#14951)
* [eslint] upgrade to 4.10.0

* [eslint-config-kibana] limit jest config to jest test files

* [ui_framework] remove trailing comma from rest-spreads

* [dashboard/tests] tag jest helpers with .test.js suffix

* explicitly import expect.js where used

* [eslint] apply auto-fixes

* [eslint] manually add/wrap some parens for compliance

* [npm] point to local packages for testing/review

* [jest] remove .test extension from jest helpers

* [ui_framework] fix trailing comma removal from 3bc661a1c8

* [packages] upgrade eslint packages
2017-11-14 20:20:37 -07:00

39 lines
1 KiB
JavaScript

import { execFile } from 'child_process';
import { all, fromNode } from 'bluebird';
export default (grunt) => {
const { config, log } = grunt;
const cwd = config.get('buildDir');
const targetDir = config.get('target');
async function exec(cmd, args) {
log.writeln(` > ${cmd} ${args.join(' ')}`);
await fromNode(cb => execFile(cmd, args, { cwd }, cb));
}
async function archives({ name, buildName, zipPath, tarPath }) {
if (/windows/.test(name)) {
await exec('zip', ['-rq', '-ll', zipPath, buildName]);
} 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);
}
}
grunt.registerTask('_build:archives', function () {
grunt.file.mkdir(targetDir);
all(
config.get('platforms').map(async platform => await archives(platform))
)
.nodeify(this.async());
});
};