文件操作 - cli.CoNbGSsT.mjs
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@nuxt/cli/dist/shared/cli.CoNbGSsT.mjs
编辑文件内容
import { promises, existsSync } from 'node:fs'; import { join } from 'pathe'; import { a as logger } from './cli.TH4BiEd5.mjs'; async function exists(path) { try { await promises.access(path); return true; } catch { return false; } } async function clearDir(path, exclude) { if (!exclude) { await promises.rm(path, { recursive: true, force: true }); } else if (existsSync(path)) { const files = await promises.readdir(path); await Promise.all( files.map(async (name) => { if (!exclude.includes(name)) { await promises.rm(join(path, name), { recursive: true, force: true }); } }) ); } await promises.mkdir(path, { recursive: true }); } function clearBuildDir(path) { return clearDir(path, ["cache", "analyze"]); } async function rmRecursive(paths) { await Promise.all( paths.filter((p) => typeof p === "string").map(async (path) => { logger.debug("Removing recursive path", path); await promises.rm(path, { recursive: true, force: true }).catch(() => { }); }) ); } async function touchFile(path) { if (await exists(path)) { return; } await promises.writeFile(path, "").catch(() => { logger.error(`Failed to create file: ${path}`); }); } export { clearBuildDir as a, clearDir as c, rmRecursive as r, touchFile as t };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件