Skip to content
Merged
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
28 changes: 26 additions & 2 deletions tasks/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,34 @@ async function packageMountebank () {

async function packageMbTest () {
await distPackage('mbTest', 'test', pkg => {
/*
* Update the mountebank dependency path from 'file:..' to 'file:../mountebank'
* In v3 lockfile format:
* 1. Update root package's dependency reference
* 2. Rename the mountebank package entry from '..' to '../mountebank'
* 3. Remove ALL other '../*' entries (these are parent's node_modules that shouldn't be here)
*/
pkg.dependencies.mountebank = 'file:../mountebank';

const lockfile = JSON.parse(fs.readFileSync('dist/test/package-lock.json'));
lockfile.packages['../mountebank'] = lockfile.packages['..'];
delete lockfile.packages['..'];

// Update the root package's dependency reference
lockfile.packages[''].dependencies.mountebank = 'file:../mountebank';

// Save the mountebank package entry before we delete it
const mountebankPackage = lockfile.packages['..'];

// Remove all package entries that start with '../' (including '..' and '../node_modules/*')
// These are from the parent directory and shouldn't be in the test package lockfile
Object.keys(lockfile.packages).forEach(key => {
if (key.startsWith('../')) {
delete lockfile.packages[key];
}
});

// Re-add only the mountebank package entry with the corrected path
lockfile.packages['../mountebank'] = mountebankPackage;

fs.writeFileSync('dist/test/package-lock.json', JSON.stringify(lockfile, null, 2));
});
}
Expand Down
Loading