Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions 15 .npmignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/.travis/
/build/
/examples/
/generate/
/guides/
/lib/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore lib? all of our js is in there?

Copy link
Collaborator Author

@johnhaley81 johnhaley81 Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib should already be 100% built and in dist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes complete and total sense and I should have realized that, but sometimes I am do the forget.

/test/
/vendor/Release/

/generate/output
/generate/**/*.json
!/generate/input/*.json
!/include
!/src

.astylerc
.editorconfig
Expand All @@ -15,8 +18,10 @@
.travis.yml
appveyor.yml

*.vcxproj
!binding.gyp

*.filters
*.sln
*.log
*.md
*.sln
*.vcxproj
2 changes: 1 addition & 1 deletion 2 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ before_install:
fi

install:
- BUILD_ONLY=true npm install
- npm install

# This is a random private key used purely for testing.
before_script:
Expand Down
1 change: 0 additions & 1 deletion 1 appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ init:
# what combinations to test
environment:
JOBS: 4
BUILD_ONLY: true
GIT_SSH: c:\projects\nodegit\vendor\plink.exe
GYP_MSVS_VERSION: 2013
matrix:
Expand Down
10 changes: 6 additions & 4 deletions 10 generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var generateMissingTests = require("./scripts/generateMissingTests");
var submoduleStatus = require("../lifecycleScripts/submodules/getStatus");

module.exports = function generate() {
console.log("[nodegit] Generating native code");

return submoduleStatus()
.then(function(statuses) {
var dirtySubmodules = statuses
Expand All @@ -14,9 +16,9 @@ module.exports = function generate() {
});

if (dirtySubmodules.length) {
console.log("WARNING - Some submodules are out-of-sync");
console.warn("[nodegit] WARNING - Some submodules are out-of-sync");
dirtySubmodules.forEach(function(submodule) {
console.log("\t" + submodule.name);
console.warn("[nodegit]\t" + submodule.name);
});
}
})
Expand All @@ -26,8 +28,8 @@ module.exports = function generate() {
generateMissingTests();
})
.catch(function(e) {
console.log("ERROR - Could not generate native code");
console.log(e);
console.error("[nodegit] ERROR - Could not generate native code");
console.error(e);
});
}

Expand Down
2 changes: 1 addition & 1 deletion 2 generate/scripts/generateJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module.exports = function generateJson() {
_.merge(enumerable, _.omit(override, ["values"]));

output.push(enumerable);
}).value();
});
Copy link
Collaborator

@maxkorp maxkorp Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need the .value to make lodash actually do the operation? I thought they were lazy about that as of v4?

Edit: Maybe that was a change going in to v3, and now thats not there in v4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. We needed it in v3 but in v4 a forEach just executes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRAISE BE TO LODASH, FOR THEY ARE IMPROVE


output = _.sortBy(output, "typeName");

Expand Down
2 changes: 0 additions & 2 deletions 2 generate/scripts/generateMissingTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const path = require("path");
const promisify = require("promisify-node");
const fse = promisify(require("fs-extra"));
const utils = require("./utils");

const testFilesPath = "../test/tests";
Expand Down
2 changes: 1 addition & 1 deletion 2 generate/scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ var Helpers = {
if (fnDef.jsFunctionName == utils.camelCase(collidingName)) {
fnDef.jsFunctionName = utils.camelCase(newName);
}
}).value();
});

if ("git_" + typeDef.typeName == fnDef.cFunctionName) {
fnDef.useAsOnRootProto = true;
Expand Down
1 change: 0 additions & 1 deletion 1 generate/scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const promisify = require("promisify-node");
const fse = require("fs-extra");

const fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion 2 lifecycleScripts/configureLibssh2.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ if (require.main === module) {
console.log("nothing to do");
}
else {
module.exports();
module.exports().done();
}
}
201 changes: 38 additions & 163 deletions 201 lifecycleScripts/install.js
Original file line number Diff line number Diff line change
@@ -1,187 +1,62 @@
var path = require("path");
var fs = require("fs");
var cp = require("child_process");
var prepareForBuild = require("./prepareForBuild");
var exec = require("../utils/execPromise");
var buildFlags = require("../utils/buildFlags");
var spawn = require("child_process").spawn;

module.exports = function install() {
var fromRegistry;
console.log("[nodegit] Running install script");

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;
}
var nodePreGyp = "node-pre-gyp";

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 (process.platform === "win32") {
nodePreGyp += ".cmd";
}

return installPrebuilt();
var args = ["install"];

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.");
},
function(err) {
console.info("[nodegit] Failed to install prebuilt binary:");
console.error(err);
console.info("[nodegit] Building manually. (You'll be here a while.)");
return prepareAndBuild();
}
if (buildFlags.mustBuild) {
console.info(
"[nodegit] Pre-built download disabled, building from source."
);
}
args.push("--build-from-source");

function pathForTool(name) {
var toolPath = path.resolve(".", "node_modules", ".bin", name);
if (process.platform == "win32") {
toolPath += ".cmd";
if (buildFlags.debugBuild) {
console.info("[nodegit] Building debug version.");
args.push("--debug");
}
return toolPath;
}

function prepareAndBuild() {
console.info("[nodegit] Regenerating and configuring code");
return prepareForBuild()
.then(function() {
return build();
})
.then(function() {
return transpileJavascript();
});
else {
args.push("--fallback-to-build");
}

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;
return new Promise(function(resolve, reject) {
var spawnedNodePreGyp = spawn(nodePreGyp, args);

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();
}
});
spawnedNodePreGyp.stdout.on("data", function(data) {
console.info(data.toString().trim());
});
}

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();
}
});
spawnedNodePreGyp.stderr.on("data", function(data) {
console.error(data.toString().trim());
});

if (electronVersion) {
target = "--target=" + electronVersion;
distUrl = "--dist-url=https://atom.io/download/atom-shell";
runtime = "--runtime=electron";
spawnedNodePreGyp.on("close", function(code) {
if (!code) {
resolve();
} else {
reject(code);
}
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();
}
});
});
}
});
})
.then(function() {
console.info("[nodegit] Completed installation successfully.");
});
};

// Called on the command line
if (require.main === module) {
module
.exports()
.catch(function(err) {
console.error(err);
return -1;
module.exports()
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish install");
console.error("[nodegit] ERROR - finished with error code: " + e);
process.exit(e);
});
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.