UNPKG

1 kBJavaScriptView Raw
1#!/usr/bin/env node
2var cp = require('child_process')
3var nps = require('path')
4var chalk = require('chalk')
5var os = require('os')
6var over = require('../lib/lib/utils/overwrite-require');
7
8var argv = process.argv.slice(2)
9if (!argv.length) {
10 console.error('\n ' + chalk.red.bold('`picidae -h`') + ' for help ')
11 process.exit(1)
12}
13
14var execSync
15if (os.platform() === 'win32') {
16 execSync = function execSync(file, argv, opts) {
17 return cp.spawnSync('node', [file].concat(argv), opts)
18 }
19}
20else {
21 execSync = function execSync(file, argv, opts) {
22 return cp.execFileSync(file, argv, opts)
23 }
24}
25
26over.logPkgLocation()
27var info = over.getInfo()
28var opts = {
29 stdio: 'inherit'
30}
31console.log('')
32try {
33if (info.type === 'local') {
34 execSync(require.resolve(nps.join(info.path.workRoot, '../../bin/picidae')), argv, opts)
35}
36else {
37 execSync(require.resolve(nps.join(info.path.localRoot, '../../bin/picidae')), argv, opts)
38}
39} catch (ex) {
40 process.exit(1)
41}
42