@zkochan/pnpm
Version:
A fast implementation of npm install
20 lines (16 loc) • 560 B
JavaScript
const fs = require('fs')
const path = require('path')
const pkgPath = path.resolve(process.cwd(), 'package.json')
const rawPkgJSON = fs.readFileSync(pkgPath, 'UTF8')
const pkgJSON = JSON.parse(rawPkgJSON)
const newPkgJSON = {}
const keys = Object.keys(pkgJSON)
for (let i = 0; i < keys.length; i++) {
if (keys[i] === 'dependencies') {
newPkgJSON.hiddenDependencies = pkgJSON.dependencies
continue
}
newPkgJSON[keys[i]] = pkgJSON[keys[i]]
}
fs.writeFileSync(pkgPath, JSON.stringify(newPkgJSON, null, 2), 'UTF8')