我花了很多时间在 Coffeescript 中构建这个美妙的 Cakefile 来构建所有东西,现在我希望能够cake build
使用与我的程序相关的另一个别名从该目录外部运行命令。
有没有办法cake build
从可执行文件中运行?我可以通过 npm 在“/bin”下执行什么?
我花了很多时间在 Coffeescript 中构建这个美妙的 Cakefile 来构建所有东西,现在我希望能够cake build
使用与我的程序相关的另一个别名从该目录外部运行命令。
有没有办法cake build
从可执行文件中运行?我可以通过 npm 在“/bin”下执行什么?
正如 Noli 所说,唯一的方法是逆向工程cake.js
或更简单地cake
从目标目录运行命令。在 Node 下,您可以通过将选项设置为所需的工作目录来使用child_process.spawn来执行此操作。cwd
看起来没有命令行选项可以做到这一点
https://github.com/jashkenas/coffee-script/blob/master/lib/cake.js#L38
exports.run = function() {
return path.exists('Cakefile', function(exists) {
var arg, args, _i, _len, _ref, _results;
if (!exists) {
throw new Error("Cakefile not found in " + (process.cwd()));
}
因此,您的进程可能需要先“cd”到 Cakefile 的目录才能运行它。(或者你可以修补咖啡脚本来争论)