文件操作 - write-json.js
返回文件管理
返回主菜单
删除本文件
文件: /usr/lib/node_modules/npm/node_modules/libnpmversion/lib/write-json.js
编辑文件内容
// 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) }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件