Skip to content

Commit

Permalink
fix: node gyp scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
elrrrrrrr committed Nov 14, 2023
1 parent 5dd5526 commit c425b7f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 3 deletions.
6 changes: 6 additions & 0 deletions integration/fixtures/gyp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"repository": "git@github.com:cnpm/rapid.git",
"dependencies": {
"fsevents": "^1.2.13"
}
}
29 changes: 28 additions & 1 deletion integration/index.2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ describe('test/index.v2.test.js', () => {
}
});

describe('node gyp', async () => {
it('should support node-gyp for npminstall', async () => {
cwd = path.join(__dirname, './fixtures/gyp');
await coffee
.fork(rapid, [ 'install', '--by=npminstall' ], {
cwd,
})
.debug()
.expect('code', 0)
.expect('stdout', /CXX\(target\) Release\/obj.target\/fse\/fsevents\.o/)
.end();
});

it('should support node-gyp for npm mode', async () => {
cwd = path.join(__dirname, './fixtures/gyp');
await coffee
.fork(rapid, [ 'install', '--by=npm' ], {
cwd,
})
.debug()
.expect('code', 0)
.expect('stdout', /CXX\(target\) Release\/obj.target\/fse\/fsevents\.o/)
.end();
});
});

describe('INIT_CWD', async () => {
it('should set INIT_CWD', async () => {
cwd = path.join(__dirname, './fixtures/init-cwd');
Expand Down Expand Up @@ -171,7 +197,6 @@ describe('test/index.v2.test.js', () => {
it('should auto clean when reinstall', async () => {
cwd = path.join(__dirname, './fixtures/esbuild');


await coffee
.fork(rapid, [
'install',
Expand Down Expand Up @@ -203,4 +228,6 @@ describe('test/index.v2.test.js', () => {
const res = await execa.command('mount', { stdio: 'pipe' });
assert(res.stdout.indexOf('integration/fixtures/esbuild/node_modules') === res.stdout.lastIndexOf('integration/fixtures/esbuild/node_modules'));
});


});
2 changes: 2 additions & 0 deletions packages/cli/lib/node-gyp-bin/node-gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
node "`dirname "$0"`/node-gyp.js" "$@"
1 change: 1 addition & 0 deletions packages/cli/lib/node-gyp-bin/node-gyp.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node "%~dp0\node-gyp.js" %*
3 changes: 3 additions & 0 deletions packages/cli/lib/node-gyp-bin/node-gyp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

return require('node-gyp/bin/node-gyp.js');
2 changes: 1 addition & 1 deletion packages/cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ exports.runScript = async (pkgDir, script, options) => {
// ignore error
}
env.PATH = [
path.join(__dirname, '../node-gyp-bin'),
path.join(__dirname, './node-gyp-bin'),
path.join(options.cwd, 'node_modules', '.bin'),
path.join(pkgDir, 'node_modules', '.bin'),
process.env.PATH,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"semver": "^7.3.8",
"urllib": "^3.16.1",
"yargs": "^17.7.2",
"yargs-parser": "^9.0.2"
"yargs-parser": "^9.0.2",
"node-gyp": "^9.0.0"
},
"homepage": "https://github.com/cnpm/rapid",
"repository": {
Expand Down
Empty file.

0 comments on commit c425b7f

Please sign in to comment.