以编程方式运行 Cakefile
我花了很多时间在 Coffeescript 中构建这个美妙的 Cakefile,它构建了所有内容,现在我希望能够使用与我的相关的另一个别名从该目录外部运行命令 cake build
程序。
有什么方法可以从可执行文件中运行蛋糕构建吗?我可以通过 npm 在“/bin”下执行一些东西?
I spent a lot of time building this wonderful Cakefile in Coffeescript that builds everything, and now I'd like to be able to run the command cake build
from outside of that directory using another alias thats relevant to my program.
Is there any way to run cake build
from within a executable file? Something I can have executed by npm under '/bin'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Noli 所说,唯一的方法是对
cake.js
进行逆向工程,或者更简单地从目标目录运行cake
命令。在 Node 下,您可以使用 child_process.spawn 来完成此操作通过将cwd
选项设置为所需的工作目录。As Noli says, the only way to do it is to either reverse-engineer
cake.js
or—more simply—run thecake
command from the target directory. Under Node, you can do that using child_process.spawn by setting thecwd
option to the desired working directory.看起来没有命令行选项可以执行此操作
https: //github.com/jashkenas/coffee-script/blob/master/lib/cake.js#L38
因此,您的进程可能需要先“cd”到 Cakefile 的目录,才能运行它。 (或者你可以修补 coffescript 以接受参数)
It looks like there's no command line option to do that
https://github.com/jashkenas/coffee-script/blob/master/lib/cake.js#L38
So your process will probably need to 'cd' to the directory of your Cakefile first, in order to run it. (Or you can patch coffescript to take an argument)