如何构建一个 Cakefile 来运行 node.js

how to build a Cakefile to run node.js

本文关键字:Cakefile node js 一个 运行 何构建 构建      更新时间:2023-09-26

目前正在24小时内完成"Teach Yourself Node.js",我希望在CoffeeScript而不是JavaScript中尽可能多地完成代码。

同时安装coffee-scriptnode

我仍然是蛋糕开发系统的新手 - 有人可以指出我如何组合一个Cakefile来加载一个简单的服务器的方向,比如server.coffee以运行演示代码?

您可以在 Cakefile 中使用 Node API 的任何部分,包括用于执行命令的child_process

使用

child_process.spawn() ,您应该能够使用:

task 'server', 'Start up the server', (options) ->
  spawn = require('child_process').spawn
  child = spawn 'coffee', [ "#{__dirname}/server" ]
  child.on 'error', console.error
  child.on 'exit', -> console.log('exit')