npm CLI robot 063afa85fe
deps: upgrade npm to 10.8.1
PR-URL: https://github.com/nodejs/node/pull/53207
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2024-05-30 11:21:05 +00:00

16 lines
483 B
JavaScript

// write the json back, preserving the line breaks and indent
const { writeFile } = require('node: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)
}