From 3ccb9008914cd0f3dbfdbba500b34d84600204d8 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Mon, 8 Jan 2024 14:16:17 +0000 Subject: [PATCH] update script comments and logging to reflect what it does --- scripts/replace-package.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/replace-package.js b/scripts/replace-package.js index da075596d..d4db2fc16 100644 --- a/scripts/replace-package.js +++ b/scripts/replace-package.js @@ -1,12 +1,10 @@ -// Replace a package with symlinks to a specific directory. // Example: -// REPLACE_PACKAGE=mongodb:/home/src/node-mongodb-native node scripts/replace-package.js -// will make 'mongodb' point to '/home/src/node-mongodb-native' in the root -// directory and all lerna packages. +// REPLACE_PACKAGE=mongodb:latest node scripts/replace-package.js +// will replace the 'mongodb' dep's version with latest in the root directory +// and all packages. 'use strict'; const fs = require('fs'); const path = require('path'); -const { pathToFileURL } = require('url'); const replacement = process.env.REPLACE_PACKAGE; if (!replacement) { @@ -21,7 +19,6 @@ const { from, to } = parsed.groups; for (const dir of ['.', ...fs.readdirSync('packages').map(dir => path.join('packages', dir))]) { const packageJson = path.join(dir, 'package.json'); if (fs.existsSync(packageJson)) { - const target = pathToFileURL(path.resolve(to)).href; const contents = JSON.parse(fs.readFileSync(packageJson)); for (const deps of [ contents.dependencies, @@ -29,7 +26,7 @@ for (const dir of ['.', ...fs.readdirSync('packages').map(dir => path.join('pack contents.optionalDependencies ]) { if (deps && deps[from]) { - console.info('Replacing', from, 'in', dir, 'with', target); + console.info(`Replacing deps[${from}]: ${deps[from]} with ${to}`); deps[from] = to; } }