diff --git a/index.js b/index.js index 3341470..01610eb 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,9 @@ async function exec(...args) { }); } -(async () => { +const TMP_DIR = `/tmp/mudl_${Math.random().toString(36).substring(7)}`; + +async function thing() { if (!process.argv[2]) { console.log('need a video'); return; @@ -30,7 +32,7 @@ async function exec(...args) { return item ? item.trim() : item; }); - const dir = await tmp.dir({ prefix: 'mudl_', unsafeCleanup: true }); + const dir = await fs.mkdir(TMP_DIR); let files = []; let inputType = null; @@ -158,4 +160,13 @@ async function exec(...args) { console.log('Finished everything, cleaning up...'); await dir.cleanup(); console.log('Done!'); -})().catch(console.error); +} + +(async () => { + try { + await thing(); + } catch (err) { + console.error(err); + await fs.rmdir(TMP_DIR, { recursive: true }); + } +})(); diff --git a/package.json b/package.json index aa99430..c588a8f 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,10 @@ "name": "mudl", "description": "nothing yet", "version": "1.0.2", - "dependencies": { - "fs-extra": "^7.0.1", - "tmp-promise": "^1.0.5" - }, "bin": { "mudl": "index.js" }, "engines": { "node": ">= 11.0.0" } -} +} \ No newline at end of file