forked from ariya/phantomjs
-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference System
laurentj edited this page Feb 5, 2013
·
1 revision
This is a living document. As the codebase is updated, we hope to keep this document updated as well. Unless otherwise stated, this document currently applies to the latest PhantomJS release: PhantomJS 1.8.0
Note: This page serves as a reference. To learn step-by-step on how to use PhantomJS, please refer to the Quick Start guide.
## Module: System ## A set of functions to access system-level functionality, modeled after the [CommonJS System proposal](http://wiki.commonjs.org/wiki/System). This also includes process-related properties.To start using, you must require
a reference to the system
module:
var system = require('system');
The following example demonstrates the same functionality as the Unix printenv
utility or the Windows set
command:
var env = require('system').env;
Object.keys(env).forEach(function(key) {
console.log(key + '=' + env[key]);
});
The following example prints all of the command-line arguments:
var args = require('system').args;
if (args.length === 1) {
console.log('Try to pass some arguments when invoking this script!');
}
else {
args.forEach(function(arg, i) {
console.log(i + ': ' + arg);
});
}