UNPKG

@ibm-adw/skill-toolkit

Version:

Developing your own skills with IBM Automation Digital Worker Skill Toolkit

51 lines (41 loc) 1.91 kB
#!/usr/bin/env node /* Licensed Materials - Property of IBM 5737-I23 Copyright IBM Corp. 2019. All Rights Reserved. U.S. Government Users Restricted Rights: Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ const fs = require('fs'); const path = require('path'); const chalk = require('chalk'); const exec = require('child_process').exec; const CLIENT_PORT = process.argv[2] || 3000; const SERVER_PORT = process.argv[3] || 8888; console.log('\nCLIENT PORT: ', chalk.cyan(CLIENT_PORT)); console.log('SERVER PORT: ', chalk.cyan(SERVER_PORT)); console.log(''); console.log(chalk.magentaBright('Starting client...\n')); console.log('Press ^C at any time to quit.'); let crossEnvPath, reactScriptsPath; if (fs.existsSync(path.resolve('.', 'node_modules', '.bin', 'cross-env')) && fs.existsSync(path.resolve('.', 'node_modules', '.bin', 'react-scripts'))) { // local install crossEnvPath = 'cross-env'; reactScriptsPath = 'react-scripts'; } else if (fs.existsSync(path.resolve('..', '..', 'node_modules', '.bin', 'cross-env')) && fs.existsSync(path.resolve('..', '..', 'node_modules', '.bin', 'react-scripts'))) { // global install crossEnvPath = path.resolve('..', '..', 'node_modules', '.bin', 'cross-env'); reactScriptsPath = path.resolve( '..', '..', 'node_modules', '.bin', 'react-scripts'); } else { // dev install crossEnvPath = path.resolve(__dirname, '..', '..', 'node_modules', '.bin', 'cross-env'); reactScriptsPath = path.resolve( __dirname, '..', '..', 'node_modules', '.bin', 'react-scripts'); } const child = exec('cd "' + __dirname + '" && ' + crossEnvPath + ' PORT=' + CLIENT_PORT + ' REACT_APP_SERVER_PORT=' + SERVER_PORT + ' ' + reactScriptsPath + ' start --color', function (err, stdout) { if (err) {throw err;} else {console.log(stdout);} } ); child.stdout.pipe(process.stdout);