Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frdr/pin-from-lockfile

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frdr/pin-from-lockfile - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

41

index.js

@@ -0,25 +1,30 @@

#!/usr/bin/env node
const { readFile, writeFile } = require("fs/promises");
const pkg = JSON.parse(await readFile("package.json", "utf8"));
const pkgLock = JSON.parse(await readFile("package-lock.json", "utf8"));
async function main() {
const pkg = JSON.parse(await readFile("package.json", "utf8"));
const pkgLock = JSON.parse(await readFile("package-lock.json", "utf8"));
const lockVersions = Object.entries(pkgLock.dependencies).reduce(
(acc, [name, { version }]) => acc.set(name, version),
new Map()
);
if (pkg.dependencies) {
pkg.dependencies = Object.keys(pkg.dependencies).reduce(
(acc, name) => ({ ...acc, [name]: lockVersions.get(name) }),
{}
const lockVersions = Object.entries(pkgLock.dependencies).reduce(
(acc, [name, { version }]) => acc.set(name, version),
new Map()
);
}
if (pkg.devDependencies) {
pkg.devDependencies = Object.keys(pkg.devDependencies).reduce(
(acc, name) => ({ ...acc, [name]: lockVersions.get(name) }),
{}
);
if (pkg.dependencies) {
pkg.dependencies = Object.keys(pkg.dependencies).reduce(
(acc, name) => ({ ...acc, [name]: lockVersions.get(name) }),
{}
);
}
if (pkg.devDependencies) {
pkg.devDependencies = Object.keys(pkg.devDependencies).reduce(
(acc, name) => ({ ...acc, [name]: lockVersions.get(name) }),
{}
);
}
await writeFile("package.json", JSON.stringify(pkg, null, 2));
}
await writeFile("package.json", JSON.stringify(pkg, null, 2));
main();
{
"name": "@frdr/pin-from-lockfile",
"version": "1.0.2",
"version": "1.0.3",
"description": "Read current versions in lockfile and pin package json to it",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc