Sha256: e760755f172de44782e1efe9f22d3702c1f371d236d5f579e1d51aa6c41d0c43
Contents?: true
Size: 1.56 KB
Versions: 173
Compression:
Stored size: 1.56 KB
Contents
const fs = require("fs"); const path = require("path"); const npm = require("npm"); const installer = require("npm/lib/install"); const { muteStderr, runAsync } = require("./helpers.js"); async function updateDependencyFile(directory, lockfileName) { const readFile = fileName => fs.readFileSync(path.join(directory, fileName)).toString(); // `force: true` ignores checks for platform (os, cpu) and engines // in npm/lib/install/validate-args.js // Platform is checked and raised from (EBADPLATFORM): // https://github.com/npm/npm-install-checks await runAsync(npm, npm.load, [{ loglevel: "silent", force: true }]); const dryRun = true; const initialInstaller = new installer.Installer(directory, dryRun, [], { packageLockOnly: true }); // A bug in npm means the initial install will remove any git dependencies // from the lockfile. A subsequent install with no arguments fixes this. const cleanupInstaller = new installer.Installer(directory, dryRun, [], { packageLockOnly: true }); // Skip printing the success message initialInstaller.printInstalled = cb => cb(); cleanupInstaller.printInstalled = cb => cb(); // There are some hard-to-prevent bits of output. // This is horrible, but works. const unmute = muteStderr(); try { await runAsync(initialInstaller, initialInstaller.run, []); await runAsync(cleanupInstaller, cleanupInstaller.run, []); } finally { unmute(); } const updatedLockfile = readFile(lockfileName); return { [lockfileName]: updatedLockfile }; } module.exports = { updateDependencyFile };
Version data entries
173 entries across 173 versions & 2 rubygems