Files

21 lines
522 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'
2012-01-15 00:13:26 +09:00
system = require 'system'
2011-06-14 11:28:51 +01:00
2012-01-15 00:13:26 +09:00
if system.args.length < 3
console.log "Usage: echoToFile.coffee DESTINATION_FILE <arguments to echo...>"
2012-05-16 09:37:26 +02:00
phantom.exit 1
2011-06-14 11:28:51 +01:00
else
content = ""
f = null
2012-01-15 00:13:26 +09:00
i = 2
while i < system.args.length
content += system.args[i] + (if i == system.args.length - 1 then "" else " ")
2011-06-14 11:28:51 +01:00
++i
try
2012-01-15 00:13:26 +09:00
f = fs.open(system.args[1], "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()