我正在寻找为Node.js编写的库 我将能够用来管理Web应用程序 我在Mercurial HG创建的本地存储库。
有人实现了类似的东西吗?
答案 0 :(得分:7)
我从未听说过这样的图书馆 - 它尚未在our mailinglist上公布。 Mercurial的稳定API是command line,所以我建议直接启动hg
并解析输出。它的设计易于筛选,您可以使用templates进一步自定义。
答案 1 :(得分:6)
我已经在npm上创建了一个名为node-hg的模块,正是出于这个原因。
它是Command Server的包装器,它通过stdin
发出命令并解析stdout
上的输出。
以下是其工作原理的示例:
var path = require("path");
var hg = require("hg");
// Clone into "../example-node-hg"
var destPath = path.resolve(path.join(process.cwd(), "..", "my-node-hg"));
hg.clone("http://bitbucket.org/jgable/node-hg", destPath, function(err, output) {
if(err) {
throw err;
}
output.forEach(function(line) {
console.log(line.body);
});
// Add some files to the repo with fs.writeFile, omitted for brevity
hg.add(destPath, ["someFile1.txt", "someFile2.txt"], function(err, output) {
if(err) {
throw err;
}
output.forEach(function(line) {
console.log(line.body);
});
var commitOpts = {
"-m": "Doing the needful"
};
// Commit our new files
hg.commit(destPath, commitOpts, function(err, output) {
if(err) {
throw err;
}
output.forEach(function(line) {
console.log(line.body);
});
});
});
});