Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Update to also support PhantomJS v2.0 #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions confess.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var confess = {

run: function () {
var cliConfig = {};
if (!this.processArgs(cliConfig, [
var argsArray = [
{
name: 'url',
def: 'http://google.com',
Expand All @@ -21,7 +21,16 @@ var confess = {
req: false,
desc: 'a local configuration file of further confess settings'
},
])) {
]
if (typeof phantom.args == 'undefined') {
// in phantom v2.0 the first argument is the scriptname
argsArray = [{
name: 'scriptname',
def: 'confess.js',
req: true,
desc: 'the name of this script'}].concat(argsArray);
}
if (!this.processArgs(cliConfig, argsArray)) {
phantom.exit();
return;
}
Expand Down Expand Up @@ -414,8 +423,10 @@ var confess = {
var a = 0;
var ok = true;
contract.forEach(function(argument) {
if (a < phantom.args.length) {
config[argument.name] = phantom.args[a];
// phantom v2.0 no longer supports phantom.args
var scriptobj = typeof phantom.args == 'undefined' ? require('system'): phantom;
if (a < scriptobj.args.length) {
config[argument.name] = scriptobj.args[a];
} else {
if (argument.req) {
console.log('"' + argument.name + '" argument is required. This ' + argument.desc + '.');
Expand Down