Skip to content

Commit

Permalink
internal: Cleanup code in _build:archives task
Browse files Browse the repository at this point in the history
This just a code cleanup - there are no functional changes to this task.
  • Loading branch information
epixa committed Jul 6, 2016
1 parent 2f2742e commit c00e49d
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tasks/build/archives.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
module.exports = function createPackages(grunt) {
let { config } = grunt;
let { resolve } = require('path');
let { execFile } = require('child_process');
let { all, fromNode } = require('bluebird');
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');
let buildPath = resolve(config.get('root'), 'build');
let exec = async (cmd, args) => {
grunt.log.writeln(` > ${cmd} ${args.join(' ')}`);
await fromNode(cb => execFile(cmd, args, { cwd: buildPath }, cb));
};

async function exec(cmd, args) {
log.writeln(` > ${cmd} ${args.join(' ')}`);
await fromNode(cb => execFile(cmd, args, { cwd }, cb));
};

let archives = async (platform) => {
if (/windows/.test(platform.name)) {
await exec('zip', ['-rq', '-ll', platform.zipPath, platform.buildName]);
async function archives({ name, buildName, zipPath, tarPath }) {
if (/windows/.test(name)) {
await exec('zip', ['-rq', '-ll', zipPath, buildName]);
} else {
await exec('tar', ['-zchf', platform.tarPath, platform.buildName]);
await exec('tar', ['-zchf', tarPath, buildName]);
}
};

grunt.registerTask('_build:archives', function () {
grunt.file.mkdir(targetDir);

all(
grunt.config.get('platforms')
.map(async platform => {

grunt.file.mkdir(targetDir);
await archives(platform);
})
config.get('platforms').map(async platform => await archives(platform))
)
.nodeify(this.async());

Expand Down

0 comments on commit c00e49d

Please sign in to comment.