我想从我的 build.js
文件安装 typings
。
例如,要安装我的 bower
deps,我使用:
var bower = require("bower");
bower.commands.install();
可以这样安装typings
吗?
最佳答案
我不这么认为,但作为替代方案,您可能可以使用 child_process
运行它。
如果您在全局范围内安装了 Typings,那么按照这些思路应该可以工作:
var spawn = require("child_process").spawn;
var typings = spawn("typings", ["install"], { shell: true });
或者如果你在本地安装了它:
var spawn = require("child_process").spawn;
var typings = spawn("./node_modules/.bin/typings", ["install"], { shell: true });
我建议阅读 child_process
文档以了解如何将输出从 stdout/stderr 传输到您的构建脚本 - 我认为否则它会静默运行。
关于typescript - 如何以编程方式安装类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38651597/