Browserify transform to fallback node.js basics in PhantomJS
This was built to be able to run option parsers like commander inside of PhantomJS.
Install the module with: npm install phantomjsify
Use it as a transform with browserify:
# Currently, we require you to skip over PhantomJS exclusive require's (e.g. `system`)
browserify --standalone commander --entry node_modules/commander/index.js --transform phantomjsify --external system --outfile vendor/commander.js
Inside of your PhantomJS script, load in the browserified file:
var program = require('./vendor/commander')
.parse(process.argv);
console.log(program); // {"options":[{"flags":"-V, --version", ... "args":[]}
It is an aggressive venture to shim over all of [node][]'s functionality, especially across multiple versions. As a result, we are taking only what we need as we need it.
Pull requests are encouraged!
- process.stdout - http://nodejs.org/api/process.html#process_process_stdout
- process.stderr - http://nodejs.org/api/process.html#process_process_stderr
- process.exit - http://nodejs.org/api/process.html#process_process_exit_code
- process.argv - http://nodejs.org/api/process.html#process_process_argv
Support this project and others by twolfson via gittip.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test
.
As of Nov 16 2013, Todd Wolfson has released this repository and its contents to the public domain.
It has been released under the UNLICENSE.