Skip to content

Commit

Permalink
Output into custom directory
Browse files Browse the repository at this point in the history
  • Loading branch information
wlaurance committed Jan 15, 2012
1 parent 1fefaa5 commit 6555b70
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/command.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ parseOptions = ->
console.warn o.output
return


writeFile = (dir, currfile, coffee) ->
outputdir = opts.output || '.'
try
if (outputdir.search '/') == -1
outputdir = outputdir.concat '/'
newPath = outputdir + dir + '/'
try
fs.statSync(newPath).isDirectory()
catch e
file.mkdirsSync(newPath)
currfile = (currfile.split '.')[0] + '.coffee'
newFile = newPath + currfile
console.warn "writing %s ", newFile
fs.writeFileSync(newFile, coffee, encoding);
catch e
console.warn e

batch = () ->

callback = (dirPath, dirs, files) ->
Expand All @@ -43,8 +61,7 @@ batch = () ->
console.warn "read file %s", readf
contents = fs.readFileSync(readf, encoding);
output = js2coffee.build(contents)
newFileName = dirPath + '/' + (f.split '.')[0] + '.coffee'
fs.writeFileSync(newFileName, output, encoding)
writeFile(dirPath, f, output)
catch e
console.warn e

Expand Down

0 comments on commit 6555b70

Please sign in to comment.