cate.js 821 B

12345678910111213141516171819202122232425262728
  1. import fs from "fs"
  2. import path from "path"
  3. fs.readdirSync("dist").forEach(file => {
  4. const pif = JSON.parse(
  5. fs
  6. .readFileSync(path.join("dist", file), "utf-8")
  7. .toString()
  8. .replace(/\/\/.*/g, "")
  9. )
  10. try {
  11. const release = parseInt(pif.RELEASE.split(".")[0])
  12. if (isNaN(release)) {
  13. throw new Error("NaN")
  14. }
  15. const dir = path.join("dist", release.toString())
  16. if (!fs.existsSync(dir)) {
  17. fs.mkdirSync(dir)
  18. }
  19. fs.copyFileSync(path.join("dist", file), path.join(dir, file))
  20. } catch (e) {
  21. const dir = path.join("dist", "unkown")
  22. if (!fs.existsSync(dir)) {
  23. fs.mkdirSync(dir)
  24. }
  25. fs.copyFileSync(path.join("dist", file), path.join(dir, file))
  26. }
  27. })