2011-06-14 14:28:51 +04:00
|
|
|
# echoToFile.coffee - Write in a given file all the parameters passed on the CLI
|
2011-09-08 20:55:50 +04:00
|
|
|
fs = require 'fs'
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require 'system'
|
2011-06-14 14:28:51 +04:00
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if system.args.length < 3
|
|
|
|
console.log "Usage: echoToFile.coffee DESTINATION_FILE <arguments to echo...>"
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit 1
|
2011-06-14 14:28:51 +04:00
|
|
|
else
|
|
|
|
content = ""
|
|
|
|
f = null
|
2012-01-14 19:13:26 +04:00
|
|
|
i = 2
|
|
|
|
while i < system.args.length
|
|
|
|
content += system.args[i] + (if i == system.args.length - 1 then "" else " ")
|
2011-06-14 14:28:51 +04:00
|
|
|
++i
|
2011-06-29 00:35:27 +04:00
|
|
|
try
|
2013-02-20 01:16:05 +04:00
|
|
|
fs.write system.args[1], content, "w"
|
2011-06-29 00:35:27 +04:00
|
|
|
catch e
|
|
|
|
console.log e
|
2011-09-08 20:55:50 +04:00
|
|
|
phantom.exit()
|