exec cs process instead of requiring cs module

https://github.com/jashkenas/coffee-script/issues/1620
the coffee-script module isn't documented, everyone seems to prefer exec
This commit is contained in:
James Campos 2011-08-30 18:48:06 -07:00
parent 221ba438f0
commit 6c36d86535
2 changed files with 8 additions and 12 deletions

View File

@ -1,19 +1,15 @@
cs = require 'coffee-script' {log} = console
fs = require 'fs' {exec} = require 'child_process'
{log} = console fs = require 'fs'
HEADER = fs.readFileSync 'header', 'utf8' HEADER = fs.readFileSync 'header', 'utf8'
INFILE = 'script.coffee' INFILE = 'script.coffee'
OUTFILE = '4chan_x.user.js' OUTFILE = '4chan_x.user.js'
build = -> build = ->
fs.readFile INFILE, 'utf8', (err, code) -> exec 'coffee --print script.coffee', (err, stdout, stderr) ->
throw err if err throw err if err
try fs.writeFile OUTFILE, HEADER + stdout, (err) ->
code = HEADER + cs.compile code
catch e
log e
fs.writeFile OUTFILE, code, (err) ->
throw err if err throw err if err
task 'build', -> task 'build', ->

View File

@ -4,6 +4,6 @@
[install nodejs and npm](https://github.com/joyent/node/wiki/Installation), [install nodejs and npm](https://github.com/joyent/node/wiki/Installation),
install [coffee-script](https://github.com/jashkenas/coffee-script/) with install [coffee-script](https://github.com/jashkenas/coffee-script/) with
`npm install -g coffee-script`, clone 4chan x, cd into it and run `npm install -g coffee-script`, clone 4chan x, cd into it and actually build
`npm link coffee-script`. actually build it with `cake build`. for development with `cake build`. for development (continuous builds), run `cake dev &`.
(continuous builds), run `cake dev &`. kill the process with `killall node`. kill the process with `killall node`.