The goal: capture console output in a log file.
All I have are console.log() operations, and I know how to use >, so I would expect this to be simple enough, right?
The Setup: my package.json scripts
"scripts": {
"test": "node ./lib/es6_global/test/Main.bs.js",
"test-ci": "npm run test > log.log"
},
So, seems simple.
Expected Result
I would expect the test command to output to the console and the test-ci command to output to the log.
Actual Result
$ node ./lib/es6_global/test/Main.bs.js # outputs expected output to terminal.
$ node ./lib/es6_global/test/Main.bs.js > log.log # outputs expected output to log file.
$ npm run test # prints two lines specifying the test script and then outputs expected output to terminal.
$ npm run test-ci # prints two lines specifying the test script, creates the log file, but does not appear to write to it.
I'm at a loss for why I can't output to the file from within a script. Like, it clearly thinks its parsing the > in the script because it doesn't output to the terminal, and it creates the log file if it doesn't exist. It just doesn't appear to write to it.
What's wild is I can enter the full command into the console with the output redirected and it does exactly what I expect. What is it about putting it inside a "run" command that silences my output?