Преглед на файлове

Remove all neovan tmp dirs at start of app, just in case.

Lee Morgan преди 4 дни
родител
ревизия
6a296bb273
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      index.js

+ 12 - 0
index.js

@@ -1,6 +1,7 @@
 import fs from "node:fs/promises";
 import path from "path";
 import {constants} from "node:fs";
+import os from "os";
 
 import parseComponent from "./parseComponent.js";
 
@@ -15,6 +16,8 @@ export default async (express, options)=>{
 
     let app = express();
 
+    removeOldTmpDirs();
+
     console.time("Build time");
 
     await fs.rm(path.join(process.cwd(), ".build/"), {recursive: true, force: true});
@@ -67,3 +70,12 @@ const findIndexFile = async (dir)=>{
     if(html.status === "fulfilled") return htmlPath;
     return null;
 }
+
+const removeOldTmpDirs = async ()=>{
+    const entries = await fs.readdir(os.tmpdir());
+    for(let i = 0; i < entries.length; i++){
+        if(entries[i].startsWith("neovan-")){
+            fs.rm(entries[i].name, {recursive: true, force: true});
+        }
+    }
+}