Skip to content

Instantly share code, notes, and snippets.

@gdoteof
Last active September 30, 2016 18:35
Show Gist options
  • Save gdoteof/9d1f195c342f0600ad9f6cae9a041205 to your computer and use it in GitHub Desktop.
Save gdoteof/9d1f195c342f0600ad9f6cae9a041205 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
var test = spawn('./test.sh', ['--fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv"', '--ecomm-last "purestyle_lists/men_selling_master.csv"']);
test.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
test.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
});
test.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
const commandLineArgs = require('command-line-args')
const optionDefinitions = [
{ name: 'fashion-last', type: String, multiple: true},
{ name: 'ecomm-last', type: String, multiple: true}
];
const options = commandLineArgs(optionDefinitions)
console.log(options);
#!/bin/bash
echo =====
echo node test.js ${*}
node test.js ${*}
echo =====
echo =====
echo node test.js "${@}"
node test.js "${@}"
echo =====
echo =====
echo node test.js "$@"
node test.js "$@"
echo =====
echo "--this one kinda works--"
echo =====
echo node test.js "$@"
node test.js $@
echo =====
@gdoteof
Copy link
Author

gdoteof commented Sep 30, 2016

ubuntu@~/automation$ node itest.js
stdout: =====
node test.js --fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv" --ecomm-last "purestyle_lists/men_selling_master.csv"

stdout: { 'fashion-last':
   [ '"purestyle_lists/MASTER',
     '9.28.16.csv"',
     '"purestyle_lists/men_tracker_master.csv"' ],
  'ecomm-last': [ '"purestyle_lists/men_selling_master.csv"' ] }

stdout: =====
=====

stdout: node test.js --fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv" --ecomm-last "purestyle_lists/men_selling_master.csv"

stdout: { 'fashion-last': [], 'ecomm-last': [] }

stdout: =====
=====

stdout: node test.js --fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv" --ecomm-last "purestyle_lists/men_selling_master.csv"

stdout: { 'fashion-last': [], 'ecomm-last': [] }

stdout: =====

stdout: --this one kinda works--
=====

stdout: node test.js --fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv" --ecomm-last "purestyle_lists/men_selling_master.csv"

stdout: { 'fashion-last':
   [ '"purestyle_lists/MASTER',
     '9.28.16.csv"',
     '"purestyle_lists/men_tracker_master.csv"' ],
  'ecomm-last': [ '"purestyle_lists/men_selling_master.csv"' ] }

stdout: =====

child process exited with code 0
ubuntu@:~/automation$ node test.js  --fashion-last "purestyle_lists/MASTER 9.28.16.csv" "purestyle_lists/men_tracker_master.csv"  --ecomm-last "purestyle_lists/men_selling_master.csv"
{ 'fashion-last':
   [ 'purestyle_lists/MASTER 9.28.16.csv',
     'purestyle_lists/men_tracker_master.csv' ],
  'ecomm-last': [ 'purestyle_lists/men_selling_master.csv' ] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment