Skip to content

Commit

Permalink
Fix lifecycleScripts/postinstall for electron/nwjs
Browse files Browse the repository at this point in the history
  • Loading branch information
John Haley committed Jun 23, 2016
1 parent 39e5fa9 commit 5119bb9
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions lifecycleScripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var rootPath = path.join(__dirname, "..");

function printStandardLibError() {
console.log(
"[ERROR] Seems like the latest libstdc++ is missing on your system!"
"[nodegit] ERROR - the latest libstdc++ is missing on your system!"
);
console.log("");
console.log("On Ubuntu you can install it using:");
Expand All @@ -19,14 +19,40 @@ function printStandardLibError() {
}

module.exports = function install() {
if (buildFlags.isGitRepo) {
// If we're building NodeGit from a git repo we aren't going to do any
// cleaning up
return Promise.resolve();
}

return exec("node dist/nodegit.js")
.catch(function(e) {
if (~e.toString().indexOf("Module version mismatch")) {
console.warn(
"[nodegit] WARN - NodeGit was built for a different version of node."
);
console.warn(
"If you are building NodeGit for electron/nwjs you can " +
"ignore this warning."
);
}
else {
throw e;
}
})
.then(function() {
// Is we're using NodeGit from a package manager then let's clean up after
// ourselves when we install successfully.
if (!buildFlags.mustBuild) {
fse.removeSync(path.join(rootPath, "vendor"));
fse.removeSync(path.join(rootPath, "src"));
fse.removeSync(path.join(rootPath, "include"));
// We can't remove the source files yet because apparently the
// "standard workflow" for native node moduels in Electron/nwjs is to
// build them for node and then nah eff that noise let's rebuild them
// again for the actual platform! Hurray!!! When that madness is dead
// we can clean up the source which is a serious amount of data.
// fse.removeSync(path.join(rootPath, "vendor"));
// fse.removeSync(path.join(rootPath, "src"));
// fse.removeSync(path.join(rootPath, "include"));

fse.removeSync(path.join(rootPath, "build/Release/*.a"));
fse.removeSync(path.join(rootPath, "build/Release/obj.target"));
}
Expand All @@ -39,11 +65,14 @@ if (require.main === module) {
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish postinstall");

if (process.pladtform !== "linux" && ~e.indexOf("libstdc++")) {
if (
process.pladtform === "linux" &&
~e.toString().indexOf("libstdc++")
) {
printStandardLibError();
}
else {
console.error(e);
console.log(e);
}

process.exit(1);
Expand Down

0 comments on commit 5119bb9

Please sign in to comment.