咖啡脚本编译 [英] Coffee script compilation

查看:116
本文介绍了咖啡脚本编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找最简单的方法来自动将咖啡文字重新编译成JS。



阅读

我需要它来观看文件夹 src / > / 文件修改,并将它们编译为连接的JavaScript文件到 lib / something.js



不可能将观看,编译和连接组合在一起。 :/

解决方案

咖啡脚本文档提供了一个例子:



观察文件以获取更改,并在每次保存文件时重新编译:

  coffee --watch  - .coffee 

如果您有要执行的特定脚本,可以使用linux命令dnotify:
http://linux.die.net/man/1/dnotify

  dnotify --all src / --execute = command 

编辑:
我在dnotify的--execute部分有一些问题 - 可能是一个错误,但这是我工作的:

  dnotify --all。 -e`coffee -o lib / --join --compile * .coffee'



如果您在命令后面附加一个&符号,例如:



<$> p $ p> dnotify --all。 -e`coffee -o lib / --join --compile * .coffee`&

它将在单独的进程中启动。要获取进程ID,可以使用:

  ps ux | awk'/ dnotify /&&& !/ awk / {print $ 2}'

然后,您可以使用this:

  kill`ps ux | awk'/ dnotify /&&& !/ awk / {print $ 2}'`

但是如果这是你的目标),你可以使用更简单的方法:

  killall dnotify 


I'm looking for simplest possible way to automatically recompile coffee scripts into JS.

Reading documentation but still having troubles to get exactly what I want.

I need it to watch folder src/ for any *.coffee files modifications and compile them into concatenated javascript file into lib/something.js.

Somehow can't combine watching, compiling and concatenating together. :/

解决方案

The coffee script documentation provides an example for this:

Watch a file for changes, and recompile it every time the file is saved:

coffee --watch --compile experimental.coffee

If you have a particular script you want to execute, you could use the linux command dnotify: http://linux.die.net/man/1/dnotify

dnotify --all src/ --execute=command

Edit: I had some problems with the --execute part of dnotify - might be a bug, but this is what I got working:

dnotify --all . -e `coffee -o lib/ --join --compile *.coffee`

That executed the compile command each time a file was modified.

If you append the command with an ampersand, like this:

dnotify --all . -e `coffee -o lib/ --join --compile *.coffee` &

it will be started in a separate process. To get the process ID, you can use this:

ps ux | awk '/dnotify/ && !/awk/ {print $2}'

And then, you can kill the process by using something like this:

kill `ps ux | awk '/dnotify/ && !/awk/ {print $2}'`

But if that's your objective (to kill by process name), you can do it in a simpler way by using:

killall dnotify

这篇关于咖啡脚本编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆