有没有适用于 Windows 的 CoffeeScript 自动编译/文件观察器?

发布于 2024-11-18 07:27:11 字数 391 浏览 1 评论 0原文

我想尝试将咖啡脚本集成到我的开发流程中。但正如我所见,我必须制作一个bat文件来迭代一组coffee文件并吐出js文件。每次我编写一个bat文件时,尽管它们可能很有用,我都会问自己:有更好的方法吗?

这让我想知道:是否有某种适用于 Windows 的应用程序可以监视目录或文件,并在保存咖啡文件时吐出一个/多个 js 文件?我正在考虑建造一个,但不想重新发明轮子。我环顾四周,发现了一些类似的东西,但没有什么比在 Windows 上“运行此命令行”更高级的了。

编辑:已经标记了一个答案,但是 10 个月后看这个答案是:grunt。因为它不仅仅是自动编译你的咖啡脚本,而且你可能需要做的不仅仅是这些才能让你的应用程序运行。

I'd like to play around with integrating coffeescript into my dev process. But as I see it, I'll have to make a bat file that iterates a set of coffee files and spits out js files. Every time I write a bat file, useful as they may be, I ask myself: is there a better way?

Which makes me wonder: is there an app of some sort for Windows that will watch a directory or a file and spit out one/many js files when a coffee file is saved? I'm thinking of building one but don't want to reinvent the wheel. I looked around and found things that were similar but nothing that elevated it beyond "run this command line" on Windows.

Edit: already marked an answer, but looking at this 10 months later the answer is: grunt. Because it'll do a lot more than just auto-compile your coffeescript and you'll probably need to do more than just that to get your app going.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

梦里寻她 2024-11-25 07:27:11
coffee --watch -o lib -c src

其中 src 是包含咖啡文件的目录,lib 是 JavaScript 输出目录。

coffee --watch -o lib -c src

where src is a directory containing your coffee files, and lib is your JavaScript output directory.

弥繁 2024-11-25 07:27:11

请参阅帖子底部的更新。

前几天我正在寻找同样的东西,并发现了这个:https://github.com/danenania/CoffeePy

这是一个简单的 python 脚本,使用 PyV8 运行 coffee-script.js

它没有做任何花哨的事情,只是递归地监视文件夹,并在任何 .coffee 文件发生更改时编译它们。它甚至没有一个简单的选择。不过,这些东西可以很容易地添加!

编辑:

我分叉了脚本并添加了 --bare--output 选项。

您可以在这里获取它:https://github.com/johtso/CoffeePy

See update at bottom of post.

I was hunting for the same thing the other day and came across this: https://github.com/danenania/CoffeePy

It's a simple python script that uses PyV8 to run coffee-script.js.

It doesn't do anything fancy, just watches a folder recursively, and compiles any .coffee files whenever they're changed. It doesn't even have a bare option. These things could be very easily added though!

Edit:

I forked the script and added --bare and --output options.

You can get it here: https://github.com/johtso/CoffeePy

川水往事 2024-11-25 07:27:11

就我个人而言,我更喜欢使用 grunt.js / yeoman 或 brunch 等构建工具来实现此目的。

grunt.js
&
咕噜咖啡

Personally, I prefer using build tools like grunt.js / yeoman or brunch for that purpose.

grunt.js
&
grunt coffee

偏闹i 2024-11-25 07:27:11

Mindscape Workbench 有一个针对 VS 2010 的内置编译器/编辑器。还没有尝试过,但看起来它比观察器/编译器更好。 Scott Hanselman 在这里发表了一篇关于它的文章:

http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench。 ASPX

Mindscape Workbench has a built in compiler/editor for VS 2010. Haven't tried it yet, but it looks like it'd be even better than a watcher/compiler. Scott Hanselman has a post about it here:

http://www.hanselman.com/blog/CoffeeScriptSassAndLESSSupportForVisualStudioAndASPNETWithTheMindscapeWebWorkbench.aspx

违心° 2024-11-25 07:27:11

我认为有一种更简单的方法,只需使用 CoffeeScript 编译器的 -w 选项

Coffee -c -w *.coffee

这将在每次更改文件时编译您所在文件夹下的所有咖啡文件(如果需要,请放置更多文件路径)。

I think there is a simplier way just using -w option of coffeescript compiler

coffee -c -w *.coffee

This will compile all coffee files under the folder you are (put more file pathes if needed) each time you change one.

能否归途做我良人 2024-11-25 07:27:11

另一种可能性:WebStorm 6。他们为 SASS 和 Coffescript 等各种下一代语言添加了内置文件观察器。

Another possibility: WebStorm 6. They've added a built in file-watcher for a variety of next-gen languages like SASS and Coffescript.

青萝楚歌 2024-11-25 07:27:11

如果您想要一种不同的方式来做到这一点,这可能会有所帮助:
http://jashkenas.github.com/coffee-script/#scripts

如果您在您的页面上包含coffeescript编译器,您可以包含“text/coffeescript”类型的文件,它们将在客户端进行编译。

警告:显然,客户端编译并不适合严肃的事情,但对于小型项目/快速开发来说完全没问题。当需要更快的速度时,在服务器上编译它们并更改 MIME 类型和文件名将变得微不足道。

If you want a different way of doing it, this might help:
http://jashkenas.github.com/coffee-script/#scripts

If you include the coffeescript compiler on your page, you can include files with a "text/coffeescript" type and they will get compiled client-side.

Word of warning: Obviously, client-side compilation is not for something serious, but its completely fine for a small project/quick development. It would then be trivial to compile them on the server and change the MIME-type and filename when something a bit quicker is necessary.

极致的悲 2024-11-25 07:27:11

CoffeeScript-dotnet 可以满足您的需求,但它是一个命令行工具。

用于编译 CoffeeScript 的命令行工具。包括一个文件系统观察器,用于在 CoffeeScript 发生更改时自动重新编译它们。大致相当于linux/mac的coffee-script节点包。

CoffeeScript-dotnet does what you want, but it is a command line tool.

Command line tool for compiling CoffeeScript. Includes a file system watcher to automatically recompile CoffeeScripts when they change. Roughly equivalent to the coffee-script node package for linux / mac.

鸢与 2024-11-25 07:27:11

这是最好的方法:
假设您的工作位于“my-project-path”文件夹中。

  1. 转到“my-project-path”的父文件夹
  2. 启动终端并输入 coffee -o my-project-path -cw my-project-path

此行将监视并编译任何名称为“ *.coffee”位于“my-project-path”文件夹中,即使它位于“my-project-path/scripts/core”或“my-project-path/test/core”中。js 文件将位于将文件夹另存为 .coffee 文件。

Here is the best way to do it:
Say your work is in "my-project-path" folder.

  1. Go to the parent folder of "my-project-path"
  2. Start a terminal and type coffee -o my-project-path -cw my-project-path

This line will watch and compile anything name as "*.coffee" in "my-project-path" folder, even if it is in "my-project-path/scripts/core" or "my-project-path/test/core".The js file will locate in the save folder as the .coffee file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文