const fs = require("fs"); const path = require("path"); const [sourceFile, targetFile] = process.argv.slice(2); if (!sourceFile || !targetFile) { console.error("请提供源文件和目标文件的路径作为参数。"); process.exit(1); } const sourcePath = path.resolve(sourceFile); const targetPath = path.resolve(targetFile); // 复制文件 fs.copyFile(sourcePath, targetPath, (err) => { if (err) { console.error("复制文件时出错:", err); process.exit(1); } console.log(`成功复制文件从 ${sourcePath} 到 ${targetPath}`); });