# nodejs

# 同步读取文件夹

fs.readdirSync(Path);

# 同步写文件

fs.writeFileSync(configPath, `content`);

# 同步读文件

fs.readFileSync(Path, "utf-8");

# 判断文件夹是否存在

fs.access(targetFile, fs.constants.F_OK, (err) => {
  if (err) {
    // 没有文件
  }
});

# 创建文件夹

fs.mkdir(path, { recursive: true }, (err: any) => {
  if (!err) {
    // 创建成功
  }
});

# 文件路径标准化(文件路径有时有反斜杠斜杠的问题)

const path = require("path");
path.normalize();

# 判断路径是否是绝对路径

const path = require("path");
path.isAbsolute(templateFilePath);
lastUpdate: 12/10/2020, 7:37:51 AM