nodejs mkdirs

laremehpe發表於2024-03-29
import path from "path";
import fs from "fs";

//注意所傳路徑必須是目錄

const mkdirs = (location) => {
  if (fs.existsSync(location)) return;
  mkdirs(path.dirname(location));
  fs.mkdirSync(location);
}

相關文章