Skip to content

Commit

Permalink
expand nightly to the exact version, force install
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxb committed Jan 8, 2024
1 parent 3ccb900 commit 226503e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .evergreen/install-npm-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ echo "MONOGDB_DRIVER_VERSION_OVERRIDE:$MONOGDB_DRIVER_VERSION_OVERRIDE"
if [[ -n "$MONOGDB_DRIVER_VERSION_OVERRIDE" ]]; then
export REPLACE_PACKAGE="mongodb:$MONOGDB_DRIVER_VERSION_OVERRIDE"
npm run replace-package
npm ci --verbose --force # force because of issues with peer deps and semver pre-releases
fi

# if we rewrote this script in javascript using just builtin node modules we could skip the npm ci above
Expand Down
13 changes: 12 additions & 1 deletion scripts/replace-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'use strict';
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const replacement = process.env.REPLACE_PACKAGE;
if (!replacement) {
Expand All @@ -15,7 +16,17 @@ if (!parsed || !parsed.groups.from || !parsed.groups.to) {
throw new Error('Invalid format for REPLACE_PACKAGE');
}

const { from, to } = parsed.groups;
function resolveTag(from, to) {
return execSync(`npm dist-tag ls ${from}@${to} | awk -F ': ' '/^${to}/ {print \$2}'`).toString().trim();
}

const { from, to: _to } = parsed.groups;

// npm install doesn't seem to do anything if you're updating a
// package-lock.json file that already has the dep to a tag like nightly, but it
// does do something if you change it to the exact version.
const to = _to === 'nightly' ? resolveTag(from, _to) : _to;

for (const dir of ['.', ...fs.readdirSync('packages').map(dir => path.join('packages', dir))]) {
const packageJson = path.join(dir, 'package.json');
if (fs.existsSync(packageJson)) {
Expand Down

0 comments on commit 226503e

Please sign in to comment.