From 80e1a01b7c633362f198f7b0db8cab815e1c6d54 Mon Sep 17 00:00:00 2001 From: Olivier Liechti Date: Wed, 8 Jun 2016 08:58:00 +0200 Subject: [PATCH 1/4] Replace then() with done(), so that error callback is not swalled by revwalk walker --- lib/revwalk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/revwalk.js b/lib/revwalk.js index d754259c6..36d60a034 100644 --- a/lib/revwalk.js +++ b/lib/revwalk.js @@ -37,7 +37,7 @@ Revwalk.prototype.walk = function(oid, callback) { this.push(oid); function walk() { - revwalk.next().then(function(oid) { + revwalk.next().done(function(oid) { if (!oid) { if (typeof callback === "function") { return callback(); From e0eb3f39eeaeeefe1f9ee920028473707f14292c Mon Sep 17 00:00:00 2001 From: John Haley Date: Wed, 8 Jun 2016 10:22:40 -0700 Subject: [PATCH 2/4] Fix install script error getting swallowed --- lifecycleScripts/install.js | 288 +++++++++++++++++++----------------- 1 file changed, 150 insertions(+), 138 deletions(-) diff --git a/lifecycleScripts/install.js b/lifecycleScripts/install.js index c9d911bd1..cde01665f 100644 --- a/lifecycleScripts/install.js +++ b/lifecycleScripts/install.js @@ -4,37 +4,38 @@ var cp = require("child_process"); var prepareForBuild = require("./prepareForBuild"); var exec = require("../utils/execPromise"); -var fromRegistry; - -try { - fs.statSync(path.join(__dirname, "..", "include")); - fs.statSync(path.join(__dirname, "..", "src")); - fs.statSync(path.join(__dirname, "..", "dist")); - fromRegistry = true; -} -catch(e) { - fromRegistry = false; -} +module.exports = function install() { + var fromRegistry; + + try { + fs.statSync(path.join(__dirname, "..", "include")); + fs.statSync(path.join(__dirname, "..", "src")); + fs.statSync(path.join(__dirname, "..", "dist")); + fromRegistry = true; + } + catch(e) { + fromRegistry = false; + } -if (!fromRegistry) { - console.info("[nodegit] Local install, no fetching allowed."); - return prepareAndBuild(); -} -if (process.env.BUILD_DEBUG) { - console.info("[nodegit] Doing a debug build, no fetching allowed."); - return prepareAndBuild(); -} -if (process.env.BUILD_ONLY) { - console.info("[nodegit] BUILD_ONLY is set to true, no fetching allowed."); - return prepareAndBuild(); -} + if (!fromRegistry) { + console.info("[nodegit] Local install, no fetching allowed."); + return prepareAndBuild(); + } + if (process.env.BUILD_DEBUG) { + console.info("[nodegit] Doing a debug build, no fetching allowed."); + return prepareAndBuild(); + } + if (process.env.BUILD_ONLY) { + console.info("[nodegit] BUILD_ONLY is set to true, no fetching allowed."); + return prepareAndBuild(); + } -return installPrebuilt(); + return installPrebuilt(); -function installPrebuilt() { - console.info("[nodegit] Fetching binary from S3."); - var npg = pathForTool("node-pre-gyp"); - return exec("\""+ npg + "\" install --fallback-to-build=false") + function installPrebuilt() { + console.info("[nodegit] Fetching binary from S3."); + var npg = pathForTool("node-pre-gyp"); + return exec("\""+ npg + "\" install --fallback-to-build=false") .then( function() { console.info("[nodegit] Completed installation successfully."); @@ -46,130 +47,141 @@ function installPrebuilt() { return prepareAndBuild(); } ); -} + } -function pathForTool(name) { - var toolPath = path.resolve(".", "node_modules", ".bin", name); - if (process.platform == "win32") { - toolPath += ".cmd"; + function pathForTool(name) { + var toolPath = path.resolve(".", "node_modules", ".bin", name); + if (process.platform == "win32") { + toolPath += ".cmd"; + } + return toolPath; } - return toolPath; -} -function prepareAndBuild() { - console.info("[nodegit] Regenerating and configuring code"); - return prepareForBuild() + function prepareAndBuild() { + console.info("[nodegit] Regenerating and configuring code"); + return prepareForBuild() .then(function() { return build(); }) .then(function() { return transpileJavascript(); }); -} + } -function transpileJavascript() { - var cmd = pathForTool("babel"); - var args = [ - "--presets", - "es2015", - "-d", - "./dist", - "./lib" - ]; - var opts = { - cwd: ".", - maxBuffer: Number.MAX_VALUE, - env: process.env, - stdio: "inherit" - }; - var home = process.platform == "win32" ? - process.env.USERPROFILE : process.env.HOME; - - opts.env.HOME = path.join(home, ".nodegit-gyp"); - - return new Promise(function(resolve, reject) { - var child = cp.spawn(cmd, args, opts); - child.on("close", function(code) { - if (code) { - reject(code); - process.exitCode = 13; - } - else { - resolve(); - } + function transpileJavascript() { + var cmd = pathForTool("babel"); + var args = [ + "--presets", + "es2015", + "-d", + "./dist", + "./lib" + ]; + var opts = { + cwd: ".", + maxBuffer: Number.MAX_VALUE, + env: process.env, + stdio: "inherit" + }; + var home = process.platform == "win32" ? + process.env.USERPROFILE : process.env.HOME; + + opts.env.HOME = path.join(home, ".nodegit-gyp"); + + return new Promise(function(resolve, reject) { + var child = cp.spawn(cmd, args, opts); + child.on("close", function(code) { + if (code) { + reject(code); + process.exitCode = 13; + } + else { + resolve(); + } + }); }); - }); -} - -function build() { - console.info("[nodegit] Everything is ready to go, attempting compilation"); - - var electronVersion = process.env.ELECTRON_VERSION; - var nwjsVersion = process.env.NWJS_VERSION; - var opts = { - cwd: ".", - maxBuffer: Number.MAX_VALUE, - env: process.env, - stdio: "inherit" - }; - - var builder = "node-gyp"; - var debug = (process.env.BUILD_DEBUG ? "--debug" : ""); - var target = ""; - var arch = (process.env.TARGET_ARCH ? - "--arch=" + process.env.TARGET_ARCH : ""); - var distUrl = ""; - var runtime = ""; - - process.argv.forEach(function(arg) { - if (~arg.indexOf("electronVersion")) { - electronVersion = arg.split("=")[1].trim(); - } - else if (~arg.indexOf("nsjwVersion")) { - nwjsVersion = arg.split("=")[1].trim(); - } - }); - - if (electronVersion) { - target = "--target=" + electronVersion; - distUrl = "--dist-url=https://atom.io/download/atom-shell"; - runtime = "--runtime=electron"; - } - else if (nwjsVersion) { - builder = "nw-gyp"; - target = "--target=" + nwjsVersion; - runtime = "--runtime=node-webkit"; } - var home = process.platform == "win32" ? - process.env.USERPROFILE : process.env.HOME; - - opts.env.HOME = path.join(home, ".nodegit-gyp"); - - var cmd = pathForTool(builder); - var args = [ - "rebuild", - debug, - target, - arch, - distUrl, - runtime - ] - .filter(function(arg) { - return arg; - }); - - return new Promise(function(resolve, reject) { - var child = cp.spawn(cmd, args, opts); - child.on("close", function(code) { - console.log(code); - if (code) { - reject(code); - process.exitCode = 13; + function build() { + console.info("[nodegit] Everything is ready to go, attempting compilation"); + + var electronVersion = process.env.ELECTRON_VERSION; + var nwjsVersion = process.env.NWJS_VERSION; + var opts = { + cwd: ".", + maxBuffer: Number.MAX_VALUE, + env: process.env, + stdio: "inherit" + }; + + var builder = "node-gyp"; + var debug = (process.env.BUILD_DEBUG ? "--debug" : ""); + var target = ""; + var arch = (process.env.TARGET_ARCH ? + "--arch=" + process.env.TARGET_ARCH : ""); + var distUrl = ""; + var runtime = ""; + + process.argv.forEach(function(arg) { + if (~arg.indexOf("electronVersion")) { + electronVersion = arg.split("=")[1].trim(); + } + else if (~arg.indexOf("nsjwVersion")) { + nwjsVersion = arg.split("=")[1].trim(); + } + }); + + if (electronVersion) { + target = "--target=" + electronVersion; + distUrl = "--dist-url=https://atom.io/download/atom-shell"; + runtime = "--runtime=electron"; } - else { - resolve(); + else if (nwjsVersion) { + builder = "nw-gyp"; + target = "--target=" + nwjsVersion; + runtime = "--runtime=node-webkit"; } + + var home = process.platform == "win32" ? + process.env.USERPROFILE : process.env.HOME; + + opts.env.HOME = path.join(home, ".nodegit-gyp"); + + var cmd = pathForTool(builder); + var args = [ + "rebuild", + debug, + target, + arch, + distUrl, + runtime + ] + .filter(function(arg) { + return arg; + }); + + return new Promise(function(resolve, reject) { + var child = cp.spawn(cmd, args, opts); + child.on("close", function(code) { + console.log(code); + if (code) { + reject(code); + process.exitCode = 13; + } + else { + resolve(); + } + }); + }); + } +}; + +// Called on the command line +if (require.main === module) { + module + .exports() + .catch(function(err) { + console.error(err); + return -1; }); - }); } From 150b7c1f158e8274e5b1fd56b6123e97b2c42e91 Mon Sep 17 00:00:00 2001 From: John Haley Date: Wed, 8 Jun 2016 15:32:12 -0700 Subject: [PATCH 3/4] Fix submodule check When installing NodeGit from npm as a dependency if the user had to build the binary it would fail on the submodule check. Now we just bypass that check on and error since the package would be published with the correct version of libgit2 in it and we don't need to grab it as a submodule at that point anyways so the check and logic is useless. --- lifecycleScripts/submodules/getStatus.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lifecycleScripts/submodules/getStatus.js b/lifecycleScripts/submodules/getStatus.js index 53c85c1f3..2fcc42d37 100644 --- a/lifecycleScripts/submodules/getStatus.js +++ b/lifecycleScripts/submodules/getStatus.js @@ -40,5 +40,11 @@ module.exports = function getStatus() { .split("\n") .map(getStatusPromiseFromLine) ); + }) + .catch(function() { + // In the case that NodeGit is required from another project via npm we + // won't be able to run submodule commands but that's ok since the + // correct version of libgit2 is published with nodegit. + return Promise.resolve([]); }); }; From c3a89ad53a311330e6f5cdd3c82ad02791e49c3e Mon Sep 17 00:00:00 2001 From: John Haley Date: Thu, 9 Jun 2016 10:09:53 -0700 Subject: [PATCH 4/4] Bump to 0.13.2 --- CHANGELOG.md | 8 ++++++++ README.md | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d69a4b9..9a68b5b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## v0.13.2 [(2016-06-09)](https://github.com/nodegit/nodegit/releases/tag/v0.13.2) + +[Full Changelog](https://github.com/nodegit/nodegit/compare/v0.13.1...v0.13.2) + +- Stop `RevWalk#walk` from swallowing errors in the callback [PR #1047](https://github.com/nodegit/nodegit/pull/1047) +- Stop swallowing errors in the install script [PR #1048](https://github.com/nodegit/nodegit/pull/1048) +- Fix initializing submodules when installing from npm [PR #1050](https://github.com/nodegit/nodegit/pull/1050) + ## v0.13.1 [(2016-06-03)](https://github.com/nodegit/nodegit/releases/tag/v0.13.1) [Full Changelog](https://github.com/nodegit/nodegit/compare/v0.13.0...v0.13.1) diff --git a/README.md b/README.md index d7047dac6..c46b32758 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ NodeGit -**Stable: 0.13.1** +**Stable: 0.13.2** ## Have a problem? Come chat with us! ## diff --git a/package.json b/package.json index 1dc406e66..e5d431d25 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.13.1", + "version": "0.13.2", "homepage": "http://nodegit.org", "keywords": [ "libgit2",