【发布时间】:2017-10-18 02:04:02
【问题描述】:
我正在构建一个应用程序来克隆一个 repo,解析 repo 中的 xml 文件并显示信息。我正在使用 simple-git npm 模块。我在我的本地系统和开发测试服务器上都有这个工作。我正在尝试将其部署到集成服务器,这是我得到的错误。我看到的一些东西说这是因为我试图克隆到的目录不存在,但它肯定存在。
这是我编写的代码,用于克隆 repo(如果它不存在)或拉取最新更改。这是一个类的方法。 this.path 是将 repo 克隆到的目录的路径。 this.repoRoot 是本地系统上 repo 根目录的路径。 this.remote 是遥控器的 url。
/**
* gets the latest version of the remote repo and specified branch by either using clone or pull
* @return {Promise<void>}
*/
getLatest() {
return new Promise((resolve, reject) => {
this.checkForDir(this.path).then((parentDirExists) => {
if (!parentDirExists) {
fs.mkdirSync(this.path);
}
}).then(() => {
this.checkForDir(this.repoRoot).then((repoExistsLocally) => {
if (!repoExistsLocally) {
git(this.path).clone(this.remote).then((cloneResult) => {
git(this.repoRoot).checkout(this.branch).then(() => {
resolve();
});
});
}
else {
git(this.repoRoot).pull().then((pullResult) => {
resolve();
});
}
})
})
})
}
提前感谢您的帮助!
【问题讨论】: