| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
SImple example app demonstrating the issue:
//package.json
{
"name": "gitnodetest",
"version": "1.0.0",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Test Joe",
"license": "MIT",
"dependencies": {
"nodegit": "0.13.0"
}
}//test.js
var NodeGit = require("nodegit");
var path = require('path');
var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));
NodeGit.Repository.init(path.resolve(`${__dirname}/tmp/`, 'testRepo'), 0).then(
(repo) => {
fse.writeFile(path.join(repo.workdir(), 'test.txt'), 'content').then(() => {
repo.refreshIndex().then(index => {
index.addByPath(path.join(repo.workdir(), 'test.txt')).then(() => {
index.write();
})
});
})
},
() => console.log('fail')
); Running this will throw an error in module.js:442 "Cannot find module './annotated_commit'" Going down in the stack trace I can see the issue is require is called from nodegit/dist/nodegit.js:746 when this line is called: importExtension("annotated_commit");
NodeGit 0.13.1 needs to be placed onto npm: bdf9c68
The core issue was fixed: #1026
/cc @johnhaley81
Whoops... thanks @gjtorikian. I'm publishing now.
Thanks for the quick reply! 😻
@NoNameProvided is this fixed for you now?
Hmm, just rerun this test case, and it still throw exceptions under the hood. ("Cannot find module './annotated_commit'") I am not sure tho if this is expected (and handled) or not. After running this test snippet a git repo is initialized but the file is not added to the index, its untracked.
@NoNameProvided I just published NodeGit 0.14.0. Can you see if that fixes this issue for you?
Other people with similar issues are seeing this kind of thing fixed in latest. Closing this, if it's still broken for you, let us know and we'll reopen
Sorry for dragging up an old thread, but is it expected that some internal extensions are missing?
I can build via postinstall just fine, but looking at the source an importExtension("annotated_commit"); call is made to require the file annotated_commit. I don't have this file, but the exception is swallowed in a try/catch statement. Should I have it? If not, why include it, and if so, where's my file and why is the exception swallowed?
Building for electron if it makes a difference. I also miss things like nodegit.Reset.TYPE - it doesn't exist on that type. (using electron remote require)
@ashleydw The extensions that are "provided" are listed in the lib/ folder. I don't know if I'd really call them "extensions" but anyway, they're all in there. If one doesn't exist, that's perfectly normal. Not every wrapped API has extra pure JavaScript code added to it.
As to your second problem, I don't really understand what is going on. Perhaps you could provide some additional information like code and error messages and so on and so forth?
OK, now I understand regarding extensions. I see in the generator that there is no check regarding if they should exist and it adds all - hence the try/catch and swallow of the exception (
| var importExtension = function(name) { |
Regarding my second part, in electron:
const remote = require('electron').remote;
const nodegit = remote.require('nodegit');
const reset = nodegit.Reset;
console.log(reset, reset.TYPE);
Results in
So it seems the extensions (https://github.com/nodegit/nodegit/blob/97ff2cdde471659bb158400c757815e4d48ba2ff/lib/reset.js) aren't being added to my object; they are being swallowed in the try/catch in the generator.
Edit: By adding console.log's throughout the code, I can see the extensions do get loaded in the initial load but not via electron's remote require. I guess my problem is there :/
| Back | FazBrowse Home | New Git URL |
I just started to play with nodegit, but I cant use it at all. Calling Repository.init command will die silently (no console output).
Inspecting the app shows that its die while trying to load the modules in nodegit/dist/nodegit.js like the blame_hunk module. For different calls I get different errors.
I am using osx.