diff --git a/.eslintrc.json b/.eslintrc.json index bfe32a4..a4f2138 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,6 @@ { "env": { - "es6": true, + "es2017": true, "node": true, "browser": true }, diff --git a/index.js b/index.js index 5271984..fcd1c95 100644 --- a/index.js +++ b/index.js @@ -62,7 +62,7 @@ const argumentArrayContains = function (args, item) { }, false); }; -module.exports = function (config) { +module.exports = async function (config) { config = Object.assign({ roundToEvenWidth: true, roundToEvenHeight: true, @@ -195,28 +195,24 @@ module.exports = function (config) { } var overallError; - return timesnap(timesnapConfig) - .then(function () { - if (convertProcess) { - convertProcess.stdin.end(); - } - }) - .then(function () { - // wait for ffmpeg to finish - if (processPromise) { - return processPromise; - } else { - return makeProcessPromise(); - } - }).catch(function (err) { - overallError = err; - log(err); - }).then(function () { - if (frameMode && !config.keepFrames) { - deleteFolder(frameDirectory); - } - if (overallError) { - throw overallError; - } - }); + try { + await timesnap(timesnapConfig); + if (convertProcess) { + convertProcess.stdin.end(); + } + if (processPromise) { + await processPromise; + } else { + await makeProcessPromise(); + } + } catch (err) { + overallError = err; + log(err); + } + if (frameMode && !config.keepFrames) { + deleteFolder(frameDirectory); + } + if (overallError) { + throw overallError; + } }; diff --git a/package-lock.json b/package-lock.json index b9e7225..c463aba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "timecut-core", - "version": "0.2.2-prerelease", + "version": "0.3.0-prerelease", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1025,9 +1025,9 @@ "dev": true }, "timesnap-core": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/timesnap-core/-/timesnap-core-0.2.1.tgz", - "integrity": "sha512-2UlSnrFtfyoG4K7sG8vNwJaqulV6bHAHHACJDMzFrMMqxvVw0cIqPQpIuIzAROeNZUAEOPvHVJRLFKHi7awe6w==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/timesnap-core/-/timesnap-core-0.3.0.tgz", + "integrity": "sha512-XW4058LZs4tU06MwIjiV5DPWQhM2ndnZuOFZA+9gFZKIfTeAR3YY4nhT6f/O6/yOq6Li8iepO0b7pabpaBjLFg==", "requires": { "sprintf-js": "1.1.1", "timeweb": "^0.1.1" diff --git a/package.json b/package.json index b567018..c256153 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timecut-core", - "version": "0.2.2-prerelease", + "version": "0.3.0-prerelease", "description": "Record smooth movies of web pages", "repository": { "type": "git", @@ -18,7 +18,7 @@ }, "license": "BSD-3-Clause", "dependencies": { - "timesnap-core": "0.2.1" + "timesnap-core": "0.3.0" }, "devDependencies": { "eslint": "^6.8.0"