#!/usr/bin/env phantomjs --ssl-protocol=any /*global phantom, respecEvents, respecConfig*/ // respec2html is a command line utility that converts a ReSpec source file to an HTML file. // Depends on PhantomJS . var page = require("webpage").create() , args = require("system").args.slice() , fs = require("fs") , timer , reportErrors = false , reportWarnings = false , errors = [] , warnings = [] ; // report console.error on stderr console.error = function () { require("system").stderr.write(Array.prototype.join.call(arguments, ' ') + '\n'); }; var eOption = args.indexOf("-e"); if (eOption !== -1) { args.splice(args.indexOf("-e"), 1); reportErrors = true; } if (args.indexOf("-w") !== -1) { args.splice(args.indexOf("-w"), 1); reportWarnings = true; } // Reading other parameters var source = args[1] , output = args[2] , timeout = isNaN(args[3]) ? 10: parseInt(args[3], 10); if (args.length < 2 || args.length > 4) { var usage = "Usage:\n phantomjs --ssl-protocol=any respec2html.js [-e] [-w] respec-source [html-output] [timeout]\n" + " respec-source ReSpec source file, or an URL to the file\n" + " [-e] Report ReSpec errors on stderr\n" + " [-w] Report ReSpec warnings on stderr\n" + " [html-output] Name for the HTML file to be generated, defaults to stdout\n" + " [timeout] An optional timeout in seconds, default is 10\n"; console.error(usage); phantom.exit(1); } // Dealing with ReSpec source being loaded with scheme-relative link // i.e.