Skip to content
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"main": "out/src/index.js",
"types": "out/src/index.d.ts",
"gypfile": false,
"scripts": {
"build:asan": "node-gyp configure build --jobs=max --address_sanitizer",
"build:tsan": "node-gyp configure build --jobs=max --thread_sanitizer",
Expand Down
15 changes: 13 additions & 2 deletions ts/test/test-no-build-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ import * as fs from 'fs';
import * as path from 'path';

describe('package manifest', () => {
const manifest = path.join(__dirname, '..', '..', 'package.json');
const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));

it('declares no npm build lifecycle scripts (Yarn Berry YN0007)', () => {
const manifest = path.join(__dirname, '..', '..', 'package.json');
const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
const scripts = pkg.scripts || {};
const hooks = ['preinstall', 'install', 'postinstall'];
const present = hooks.filter(name => scripts[name] !== undefined);
assert.deepStrictEqual(present, []);
});

it('opts out of node-gyp on install via gypfile:false (npm implicit rebuild)', () => {
// binding.gyp lives in the dev tree (excluded from the published tarball).
// Without gypfile:false, npm's publish-time normalization synthesizes
// "gypfile": true and "install": "node-gyp rebuild" into the registry
// manifest, so consumers run node-gyp rebuild against a missing
// binding.gyp and the install fails. Pinning gypfile:false suppresses
// that hook while keeping the manifest free of lifecycle scripts.
assert.strictEqual(pkg.gypfile, false);
});
});
Loading