Files

20 lines
497 B
CoffeeScript
Raw Permalink Normal View History

2011-06-14 11:28:51 +01:00
# echoToFile.coffee - Write in a given file all the parameters passed on the CLI
2011-09-08 09:55:50 -07:00
fs = require 'fs'
2011-06-14 11:28:51 +01:00
if phantom.args.length < 2
console.log "Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>"
phantom.exit()
else
content = ""
f = null
i = 1
while i < phantom.args.length
content += phantom.args[i] + (if i == phantom.args.length - 1 then "" else " ")
++i
try
f = fs.open(phantom.args[0], "w")
2011-06-14 11:28:51 +01:00
f.writeLine content
catch e
console.log e
2011-09-08 09:55:50 -07:00
phantom.exit()