mirror of
https://github.com/ariya/phantomjs.git
synced 2024-09-19 16:48:07 +03:00
3807b9dc4d
* This is implemented with a javascript-shim
21 lines
552 B
JavaScript
21 lines
552 B
JavaScript
// echoToFile.js - Write in a given file all the parameters passed on the CLI
|
|
|
|
if (phantom.args.length < 2) {
|
|
console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>");
|
|
phantom.exit();
|
|
} else {
|
|
var content = '',
|
|
f = null;
|
|
for ( i= 1; i < phantom.args.length; ++i ) {
|
|
content += phantom.args[i] + (i === phantom.args.length-1 ? '' : ' ');
|
|
}
|
|
|
|
try {
|
|
f = fs.open(phantom.args[0], "w");
|
|
f.writeLine(content);
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
|
|
phantom.exit();
|
|
} |