diff --git a/app.js b/app.js index 2625f65..49fd614 100644 --- a/app.js +++ b/app.js @@ -30,6 +30,7 @@ di.require('os'); di.require('electron'); di.require('deepmerge'); di.require('uuid'); +di.require('tmp'); di.require('lodash', '_'); di.require('fs-extra', 'fs'); di.require('js-yaml', 'yaml'); diff --git a/commands/render.js b/commands/render.js index f6eb2d5..905840b 100644 --- a/commands/render.js +++ b/commands/render.js @@ -5,6 +5,11 @@ * @author Mohammad Fares */ +/** + * The directory to render the frames into + */ +var renderDir = tmp.dirSync({ unsafeCleanup: true }).name; + /** * Create a progress bar for processing frames * @@ -115,7 +120,7 @@ function renderFrames(records, options) { // Execute the rendering process var render = di.spawn( di.electron, - [di.path.join(ROOT_PATH, "render/index.js"), options.step], + [di.path.join(ROOT_PATH, "render/index.js"), renderDir, options.step,], { detached: false } ); diff --git a/package-lock.json b/package-lock.json index 1a35770..1b47cd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "request": "^2.88.2", "require-dir": "^1.1.0", "string-argv": "0.0.2", + "tmp": "^0.2.1", "uuid": "^3.4.0", "yargs": "^17.7.2" }, @@ -587,7 +588,6 @@ }, "node_modules/balanced-match": { "version": "1.0.2", - "dev": true, "license": "MIT" }, "node_modules/base64-js": { @@ -640,7 +640,6 @@ }, "node_modules/brace-expansion": { "version": "1.1.11", - "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -948,7 +947,6 @@ }, "node_modules/concat-map": { "version": "0.0.1", - "dev": true, "license": "MIT" }, "node_modules/console-control-strings": { @@ -1378,6 +1376,17 @@ "node": ">=4" } }, + "node_modules/external-editor/node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, "node_modules/extract-zip": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", @@ -1472,7 +1481,6 @@ }, "node_modules/fs.realpath": { "version": "1.0.0", - "dev": true, "license": "ISC" }, "node_modules/function-bind": { @@ -1593,7 +1601,6 @@ }, "node_modules/glob": { "version": "7.2.3", - "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", @@ -1878,7 +1885,6 @@ }, "node_modules/inflight": { "version": "1.0.6", - "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -2331,7 +2337,6 @@ }, "node_modules/minimatch": { "version": "3.1.2", - "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -2471,7 +2476,8 @@ }, "node_modules/os-tmpdir": { "version": "1.0.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", "engines": { "node": ">=0.10.0" } @@ -2516,7 +2522,6 @@ }, "node_modules/path-is-absolute": { "version": "1.0.1", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -3396,13 +3401,28 @@ "license": "MIT" }, "node_modules/tmp": { - "version": "0.0.33", - "license": "MIT", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", "dependencies": { - "os-tmpdir": "~1.0.2" + "rimraf": "^3.0.0" }, "engines": { - "node": ">=0.6.0" + "node": ">=8.17.0" + } + }, + "node_modules/tmp/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/tough-cookie": { diff --git a/package.json b/package.json index 976b5c7..c2f87a3 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "request": "^2.88.2", "require-dir": "^1.1.0", "string-argv": "0.0.2", + "tmp": "^0.2.1", "uuid": "^3.4.0", "yargs": "^17.7.2" }, diff --git a/render/index.js b/render/index.js index 86eb042..eca1360 100644 --- a/render/index.js +++ b/render/index.js @@ -15,17 +15,17 @@ const os = require('os'); let mainWindow = null; /** - * The temporary rendering directory's path + * The directory to render the frames into * @type {String} */ -var renderDir = path.join(__dirname, 'frames'); +const renderDir = process.argv[2]; /** * The step option * To reduce the number of rendered frames (step > 1) * @type {Number} */ -var step = process.argv[2] || 1; +const step = process.argv[3] || 1; // Hide the Dock for macOS if (os.platform() == 'darwin') {