Further changes for the Use cases on the live site.
[yaffs-website] / node_modules / phantomjs-prebuilt / lib / phantom / examples / echoToFile.js
1 // echoToFile.js - Write in a given file all the parameters passed on the CLI
2 "use strict";
3 var fs = require('fs'),
4     system = require('system');
5
6 if (system.args.length < 3) {
7     console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>");
8     phantom.exit(1);
9 } else {
10     var content = '',
11         f = null,
12         i;
13     for ( i= 2; i < system.args.length; ++i ) {
14         content += system.args[i] + (i === system.args.length-1 ? '' : ' ');
15     }
16
17     try {
18         fs.write(system.args[1], content, 'w');
19     } catch(e) {
20         console.log(e);
21     }
22
23     phantom.exit();
24 }