@frdr/pin-from-lockfile
Advanced tools
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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1118
23