UNPKG

@arc-fusion/cli

Version:

CLI for running Arc Fusion on your local machine

52 lines (44 loc) 1.23 kB
#!/usr/bin/env node 'use strict' const { IS_GLOBAL, LOCAL_SCRIPT_PATH, PROJECT_ROOT } = require('./environment') const GLOBAL_COMMANDS = [ 'clean', 'help', 'init', 'nuke' ] const args = process.argv.slice(2) const command = args[0] || 'help' if (IS_GLOBAL && !GLOBAL_COMMANDS.includes(command)) { try { // ensure the script exists require.resolve(LOCAL_SCRIPT_PATH) } catch (_) { console.error(` --------------------------------------------------------- | Couldn't find locally-installed fusion scripts. | | Have you installed @arc-fusion/cli in your project? | | > npm install --save-dev @arc-fusion/cli@latest | --------------------------------------------------------- `) process.exit(-1) } const spawn = require('./utils/spawn') // can't use `npx fusion`; if they haven't installed @arc-fusion/cli locally, it will recursively call this same global script // can't use `npm run fusion` in case they didn't do `fusion init` or overwrote those scripts // just call the script file directly spawn( 'node', [LOCAL_SCRIPT_PATH].concat(args), { cwd: PROJECT_ROOT, stdio: 'inherit' } ) } else { require('./commands') }