#!/usr/bin/env node
import osia from '.';
import minimist from 'minimist';
import list from 'cli-list';
import routine from 'promise-routine';
import { join } from 'path';

const args = process.argv.slice(2);
const sets = list(args);
const opts = minimist(args);
const tasks = [];

// Setup CLI for routine
if (sets.length > 1 || opts.i) {
  sets.forEach(set => {
    const mic = minimist(set.slice(1));
    tasks.push([set[0], mic, mic._]);
  });
} else {
  sets[0].forEach(task => tasks.push([task, {}, {}]));
}

// Run the config, which defines the tasks.
require(join(process.cwd(), 'osia.js'));

// Start
routine((...o) => osia.run(...o), ...tasks);

#!/usr/bin/env node
import osia from '.';
import minimist from 'minimist';
import list from 'cli-list';
import routine from 'promise-routine';
import { join } from 'path';

const args = process.argv.slice(2);
const opts = minimist(args, { boolean: true });
const sets = list(opts._);
const tasks = [];

// Setup CLI for routine
if (sets.length > 1 || opts.i) {
  sets.forEach(set => {
    const mic = minimist(set);
    tasks.push([set[0], mic, mic._.slice(1)]);
  });
} else {
  sets[0].forEach(task => tasks.push([task, {}, {}]));
}

if (opts.b || opts.babel) {
  require(require.resolve('babel-register'));
}

// Run the config, which defines the tasks.
require(join(process.cwd(), 'osia.js'));

// Start
routine((...o) => osia.run(...o), ...tasks);

Add babel-register under -b flag for ES6 tasks