Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get node gyp using prebuild #4

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 1 addition & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
node: [20]
os:
- name: darwin
architecture: arm64
host: macos-13
host: macos-14

- name: linux
architecture: x86-64
host: ubuntu-20.04
env:
CC: clang
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh_tests/id_rsa

npm install --ignore-scripts
npm run generate
npm install
npm test

Expand Down Expand Up @@ -81,5 +83,7 @@ jobs:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh_tests/id_rsa

npm install --ignore-scripts
npm run generate
npm install
npm test
3 changes: 0 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
/src/
/vendor/

# we do need the libgit2.gyp file though, so node-gyp can run
!/vendor/libgit2.gyp

.astylerc
.editorconfig
.gitignore
Expand Down
46 changes: 11 additions & 35 deletions lifecycleScripts/preinstall.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
var path = require("path");
var local = path.join.bind(path, __dirname);

var exec = require(local("../utils/execPromise"));
var buildFlags = require(local("../utils/buildFlags"));

module.exports = function prepareForBuild() {
console.log("[nodegit] Running pre-install script");

return exec("npm -v")
.then(
function(npmVersion) {
if (npmVersion.split(".")[0] < 3) {
console.log(
"[nodegit] npm@2 installed, pre-loading required packages"
);
return exec("npm install --ignore-scripts");
}

return Promise.resolve();
},
function() {
// We're installing via yarn, so don't
// care about compability with npm@2
}
)
.then(function() {
if (buildFlags.isGitRepo) {
var submodules = require(local("submodules"));
var generate = require(local("../generate"));
return submodules()
.then(function() {
return generate();
});
}
if (buildFlags.isGitRepo) {
var submodules = require(local("submodules"));
var generate = require(local("../generate"));
return submodules().then(function () {
return generate();
});
}
};

// Called on the command line
if (require.main === module) {
module.exports()
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish preinstall");
console.error(e);
process.exit(1);
});
module.exports().catch(function (e) {
console.error("[nodegit] ERROR - Could not finish preinstall");
console.error(e);
process.exit(1);
});
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"generateJson": "node generate/scripts/generateJson",
"generateMissingTests": "node generate/scripts/generateMissingTests",
"generateNativeCode": "node generate/scripts/generateNativeCode",
"install": "node lifecycleScripts/preinstall.js && node-gyp-build",
"generate": "node lifecycleScripts/preinstall.js",
"install": "node-gyp-build",
"installDebug": "BUILD_DEBUG=true npm install",
"lint": "jshint lib test/tests test/utils lifecycleScripts",
"mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
Expand Down