bin/waigo

Summary

Maintainability
Test Coverage
#!/usr/bin/env node

"use strict";

var path = require('path'),
  shell = require('shelljs');


// if node <0.11 then no can do
var semver = require('semver');
if (semver.lt(process.version, '4.0.0')) {
  throw new Error('Node v4+ required');
}


// ['node', '../../bin/waigo', 'arg1', ...]
var cliArgs = process.argv.slice(2);


// by default let's assume waigo-cli is in this folder
var pathToWaigoCli = path.join(__dirname, 'waigo-cli.js');

// check to see if we have a local installation of Waigo we can use
// (we'll assume that the CLI is always run in the project root folder, where 
// node_modules also resides)
var pathToLocalWaigoCli = 
  path.join(process.cwd(), 'node_modules', 'waigo', 'bin', 'waigo-cli.js');

if (shell.test('-f', pathToLocalWaigoCli)) {
  pathToWaigoCli = pathToLocalWaigoCli;
}

require(pathToWaigoCli);