npm CLI robot c923ce7414
deps: upgrade npm to 10.7.0
PR-URL: https://github.com/nodejs/node/pull/52767
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2024-05-01 06:53:22 +00:00

16 lines
478 B
JavaScript

// write the json back, preserving the line breaks and indent
const { writeFile } = require('fs/promises')
const kIndent = Symbol.for('indent')
const kNewline = Symbol.for('newline')
module.exports = async (path, pkg) => {
const {
[kIndent]: indent = 2,
[kNewline]: newline = '\n',
} = pkg
delete pkg._id
const raw = JSON.stringify(pkg, null, indent) + '\n'
const data = newline === '\n' ? raw : raw.split('\n').join(newline)
return writeFile(path, data)
}