diff --git a/package.json b/package.json index 00a6b8c..6e895dc 100644 --- a/package.json +++ b/package.json @@ -1,50 +1,59 @@ { - "name": "github-bot", - "description": "Github bot", - "version": "0.0.1", - "main": "src/app.js", - "scripts": {}, - "repository": { - "type": "git", - "url": "git+https://github.com/xuexb/github-bot.git" + "name": "github-bot", + "description": "Github bot", + "version": "0.0.1", + "main": "src/app.js", + "scripts": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/xuexb/github-bot.git" + }, + "author": "xuexb ", + "license": "MIT", + "bugs": { + "url": "https://github.com/xuexb/github-bot/issues" + }, + "homepage": "https://github.com/xuexb/github-bot#readme", + "dependencies": { + "cryptiles": "3.1.2", + "crypto": "^1.0.1", + "dotenv": "^4.0.0", + "github": "^11.0.0", + "koa": "^2.3.0", + "koa-bodyparser": "^4.2.0", + "require-dir": "^0.3.2", + "string-template": "^1.0.0" + }, + "engines": { + "node": ">= 4" + }, + "config": { + "ghooks": { + "commit-msg": "validate-commit-msg" }, - "author": "xuexb ", - "license": "MIT", - "bugs": { - "url": "https://github.com/xuexb/github-bot/issues" + "validate-commit-msg": { + "types": [ + "feat", + "fix", + "docs", + "style", + "test", + "chore", + "revert", + "close" + ] }, - "homepage": "https://github.com/xuexb/github-bot#readme", - "dependencies": { - "cryptiles": "3.1.2", - "crypto": "^1.0.1", - "dotenv": "^4.0.0", - "github": "^11.0.0", - "koa": "^2.3.0", - "koa-bodyparser": "^4.2.0", - "require-dir": "^0.3.2", - "string-template": "^1.0.0" - }, - "engines": { - "node": ">= 4" - }, - "config": { - "ghooks": { - "commit-msg": "validate-commit-msg" - }, - "validate-commit-msg": { - "types": ["feat", "fix", "docs", "style", "test", "chore", "revert", "close"] - }, - "github-bot": { - "lableToAuthor": { - "bug": "xuexb", - "enhancement": "xuexb", - "question": "xuexb" - } - } - }, - "os": ["darwin", "linux"], - "devDependencies": { - "ghooks": "^2.0.0", - "validate-commit-msg": "^2.14.0" + "github-bot": { + "lableToAuthor": { + "bug": "xuexb", + "enhancement": "xuexb", + "question": "xuexb" + } } + }, + "devDependencies": { + "ghooks": "^2.0.0", + "git-pull-or-clone": "^1.1.0", + "validate-commit-msg": "^2.14.0" + } } diff --git a/src/modules/releases/autoReleaseNote.js b/src/modules/releases/autoReleaseNote.js index e3c1d57..bdb10e8 100644 --- a/src/modules/releases/autoReleaseNote.js +++ b/src/modules/releases/autoReleaseNote.js @@ -75,7 +75,7 @@ module.exports = on => { body: body.join('\n') }); } - }); + }).catch(err => console.error(err)); }); }); } diff --git a/src/utils.js b/src/utils.js index 2c85e02..7c808d7 100755 --- a/src/utils.js +++ b/src/utils.js @@ -9,6 +9,7 @@ const fs = require('fs'); const crypto = require('crypto'); const {fixedTimeComparison} = require('cryptiles'); const {execSync, exec} = require('child_process'); +const gitPullOrClone = require('git-pull-or-clone'); const utils = { mentioned(body) { @@ -85,22 +86,16 @@ const utils = { * * @return {Promise} */ - updateRepo({repo}) { + updateRepo({url, repo}) { const repoDir = path.resolve(__dirname, '../github/', repo); - if (!utils.isDirectory(repoDir)) { - throw new Error(`${repoDir} 不是github目录!`); - } - return new Promise((resolve, reject) => { - exec(`cd ${repoDir} && git pull`, err => { + gitPullOrClone(url, repoDir, err => { if (err) { return reject(err); } - setTimeout(() => { - resolve(repoDir); - }, 1000); + resolve(repoDir); }); }); },