如何在发布到NPM之前编译coffeescript? [英] How do I compile coffeescript before publishing to NPM?

查看:164
本文介绍了如何在发布到NPM之前编译coffeescript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CoffeeScript中写了一个简单的模块,但我想将编译的JavaScript发布到NPM。我不想每次手动运行咖啡命令,这太多打字,我可能会忘记和发布stale js现在,然后。

I wrote a simple module in CoffeeScript, but I want to publish the compiled JavaScript to NPM. I don't want to manually run the coffee command each time, that's too much typing and I'll probably forget and publish stale js every now and then.

我知道npm有一些组合 package.json脚本钩子和CoffeeScript cli参数,这将执行的伎俩,但我忘记了细节。

I know there's some combination of npm package.json script hooks and CoffeeScript cli arguments that will do the trick, but I forget the particulars. How's it go again?

推荐答案

常见目录结构看起来像

"scripts": {
  "prepublish": "coffee --compile --output lib/ src/"
}

如果你还想在运行测试之前编译coffeescript,你可能想把编译步骤作为一个可重复使用的脚本:

If you also want to compile coffeescript before running tests, you likely want to pull the compilation step out as a reusable script:

"scripts": {
  "pretest": "npm run compile",
  "prepublish": "npm run compile",
  "test": "mocha",
  "compile": "coffee --compile --output lib/ src/"
}

这篇关于如何在发布到NPM之前编译coffeescript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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