August 15, 2013

npmでCoffeeScriptをインストールしてコンパイルしてみるメモ

メモです。
# CoffeeScriptのインストール
$ npm install -g coffee-script

# hello.coffeeの作成
$ mkdir coffee
$ cd coffee
$ vim hello.coffee

# hello.coffeeに以下を記述
console.log 'hello'

# コンパイルと内容の確認
$ coffee -c hello.coffee
$ more hello.js
// Generated by CoffeeScript 1.6.3
(function() {
  console.log('hello');

}).call(this);

# ヘルプコマンドを実行
$ coffee -h

Usage: coffee [options] path/to/script.coffee -- [args]

If called without options, `coffee` will run your script.

  -b, --bare         compile without a top-level function wrapper
  -c, --compile      compile to JavaScript and save as .js files
  -e, --eval         pass a string from the command line as input
  -h, --help         display this help message
  -i, --interactive  run an interactive CoffeeScript REPL
  -j, --join         concatenate the source CoffeeScript before compiling
  -m, --map          generate source map and save as .map files
  -n, --nodes        print out the parse tree that the parser produces
   --nodejs       pass options directly to the "node" binary
  -o, --output       set the output directory for compiled JavaScript
  -p, --print        print out the compiled JavaScript
  -s, --stdio        listen for and compile scripts over stdio
  -l, --literate     treat stdio as literate style coffee-script
  -t, --tokens       print out the tokens that the lexer/rewriter produce
  -v, --version      display the version number
  -w, --watch        watch scripts for changes and rerun commands
変更の監視は
$ coffee -wc *.coffee
で出来ました。

No comments:

Post a Comment