I am working on a project using electron and nodegit, and I recently updated my dependencies. After solving the compatibility issues, I found two versions of nodegit and electron that work. But upon testing it, I found that async nodegit operations fail, while the synchronous ones work fine. Here's a code example that does not work:
const pathToRepo = require('path').resolve(path);
Git.Repository.open(pathToRepo)
.then((repo) => {
console.log(repo);
})
.catch( (err) => {
console.log(err);
});
Upon executing it, the promise returns an error which is caught by the catch block, and upon outputting the value on the console it simple displays true
, and gives no additional information.
Also, I had updated node from 5 to 6.3 before updating my dependencies.
electron-prebuilt: 0.37.8
nodegit: 0.13.0
electron-prebuilt: 1.2.1
nodegit: 0.14.1
EDIT: Solved by adding an npm script:
"rebuild": "npm rebuild --runtime=electron --target=1.2.1 disturl=https://atom.io/download/atom-shell --build-from-source",
and running npm run rebuild
.
nodegit
contains a native NodeJS module, native modules must be rebuilt to target the Electron version you use them with. Instructions for rebuilding native modules can be found at http://electron.atom.io/docs/tutorial/using-native-node-modules/