juliangruber / browser-run

Run code inside a browser from the command line
447 stars 62 forks source link

Std stream not working correctly #100

Closed SteveALee closed 8 years ago

SteveALee commented 8 years ago

I'm on windows but using git for windows bash

While browserify -t babelify src/test.js | browser-run -p 8080 works just fine

$ browserify -t babelify src/test.js -o lib/script-compiled.js
$ cat lib/script-compiled.js | browser-run -p 8080

Does not. neither does

$ browser-run -p 8080 < lib/script-compiled.js

I can't figure why this strange behaviour might be happening

SteveALee commented 8 years ago

PS the reason I tried this was I have a custom HTML I want to use which was not working with cat. So tried with working javascript first

PPS The readme says you need to provide /recorder.js in a custom html but as far as I can see this is injected anyway.

SteveALee commented 8 years ago

ah, my bad. I was not quoting things correctly.

FYI I am using this in a npm script but as npm always runs cmd on windows I have to prefix with bash -c. But I forgot pipes require the command string to quoted thus:

"test": "bash -c \"cat index.html | browser-run --input html -p 8080\"",

I won't close in case you wanted to respond to the PS and PPS

Rats, now I get Syntax errors "unexpected identifier" in reporter.h when using Chrome

if (old) old.apply(console, arguments);

seems to be the apply which should be ok. Time to debug.

SteveALee commented 8 years ago

Ah it turns out to be 'not supported' being returned by the embedded server for my globally included scripts in a /src folder. Setting the --static option to . fixed that. Would probably be a sensible default.