diff --git a/CHANGELOG.md b/CHANGELOG.md index b5de8be5f..22a76661c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [4.4.2] - 2023-10-16 + ### Changed +- Fix FFmpeg decompression. - Auto generate docs from JSDoc comments. - Improve TypeScript type definitions. - Fix get mode. diff --git a/package-lock.json b/package-lock.json index bc40208f7..6ebe5f50b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nw-builder", - "version": "4.4.1", + "version": "4.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nw-builder", - "version": "4.4.1", + "version": "4.4.2", "license": "MIT", "dependencies": { "cli-progress": "^3.12.0", @@ -14,7 +14,7 @@ "glob": "^10.3.10", "plist": "^3.1.0", "rcedit": "^4.0.0", - "winston": "^3.10.0", + "winston": "^3.11.0", "yargs": "^17.7.2" }, "bin": { @@ -22,17 +22,17 @@ }, "devDependencies": { "concurrently": "^8.2.1", - "eslint": "^8.50.0", + "eslint": "^8.51.0", "eslint-config-tjw-jsdoc": "^1.0.4", "gh-pages": "^6.0.0", "jsdoc": "^4.0.2", "jsdoc-to-markdown": "^8.0.0", "prettier": "^3.0.3", - "selenium-webdriver": "^4.13.0", - "vitepress": "^1.0.0-rc.20" + "selenium-webdriver": "^4.14.0", + "vitepress": "^1.0.0-rc.21" }, "engines": { - "node": ">= v16.20.1 || >= v18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.2 || >= 20.8.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -731,9 +731,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.50.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.50.0.tgz", - "integrity": "sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==", + "version": "8.51.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.51.0.tgz", + "integrity": "sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -945,9 +945,9 @@ "integrity": "sha512-6tOUG+nVHn0cJbVp25JFayS5UE6+xlbcNF9Lo9mU7U0zk3zeUShZied4YEQZjy1JBF043FSkdXw8YkUJuVtB5g==" }, "node_modules/@types/web-bluetooth": { - "version": "0.0.17", - "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.17.tgz", - "integrity": "sha512-4p9vcSmxAayx72yn70joFoL44c9MO/0+iVEBIQXe3v2h2SiAsEIo/G5v6ObFWvNKRFjbrVadNf9LqEEZeQPzdA==", + "version": "0.0.18", + "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.18.tgz", + "integrity": "sha512-v/ZHEj9xh82usl8LMR3GarzFY1IrbXJw5L4QfQhokjRV91q+SelFqxQWSep1ucXEZ22+dSTwLFkXeur25sPIbw==", "dev": true }, "node_modules/@vue/compiler-core": { @@ -1001,9 +1001,9 @@ } }, "node_modules/@vue/devtools-api": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.5.0.tgz", - "integrity": "sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.5.1.tgz", + "integrity": "sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==", "dev": true }, "node_modules/@vue/reactivity": { @@ -1069,15 +1069,15 @@ "dev": true }, "node_modules/@vueuse/core": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-10.4.1.tgz", - "integrity": "sha512-DkHIfMIoSIBjMgRRvdIvxsyboRZQmImofLyOHADqiVbQVilP8VVHDhBX2ZqoItOgu7dWa8oXiNnScOdPLhdEXg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-10.5.0.tgz", + "integrity": "sha512-z/tI2eSvxwLRjOhDm0h/SXAjNm8N5ld6/SC/JQs6o6kpJ6Ya50LnEL8g5hoYu005i28L0zqB5L5yAl8Jl26K3A==", "dev": true, "dependencies": { - "@types/web-bluetooth": "^0.0.17", - "@vueuse/metadata": "10.4.1", - "@vueuse/shared": "10.4.1", - "vue-demi": ">=0.14.5" + "@types/web-bluetooth": "^0.0.18", + "@vueuse/metadata": "10.5.0", + "@vueuse/shared": "10.5.0", + "vue-demi": ">=0.14.6" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -1110,14 +1110,14 @@ } }, "node_modules/@vueuse/integrations": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-10.4.1.tgz", - "integrity": "sha512-uRBPyG5Lxoh1A/J+boiioPT3ELEAPEo4t8W6Mr4yTKIQBeW/FcbsotZNPr4k9uz+3QEksMmflWloS9wCnypM7g==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-10.5.0.tgz", + "integrity": "sha512-fm5sXLCK0Ww3rRnzqnCQRmfjDURaI4xMsx+T+cec0ngQqHx/JgUtm8G0vRjwtonIeTBsH1Q8L3SucE+7K7upJQ==", "dev": true, "dependencies": { - "@vueuse/core": "10.4.1", - "@vueuse/shared": "10.4.1", - "vue-demi": ">=0.14.5" + "@vueuse/core": "10.5.0", + "@vueuse/shared": "10.5.0", + "vue-demi": ">=0.14.6" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -1202,21 +1202,21 @@ } }, "node_modules/@vueuse/metadata": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-10.4.1.tgz", - "integrity": "sha512-2Sc8X+iVzeuMGHr6O2j4gv/zxvQGGOYETYXEc41h0iZXIRnRbJZGmY/QP8dvzqUelf8vg0p/yEA5VpCEu+WpZg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-10.5.0.tgz", + "integrity": "sha512-fEbElR+MaIYyCkeM0SzWkdoMtOpIwO72x8WsZHRE7IggiOlILttqttM69AS13nrDxosnDBYdyy3C5mR1LCxHsw==", "dev": true, "funding": { "url": "https://github.com/sponsors/antfu" } }, "node_modules/@vueuse/shared": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-10.4.1.tgz", - "integrity": "sha512-vz5hbAM4qA0lDKmcr2y3pPdU+2EVw/yzfRsBdu+6+USGa4PxqSQRYIUC9/NcT06y+ZgaTsyURw2I9qOFaaXHAg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-10.5.0.tgz", + "integrity": "sha512-18iyxbbHYLst9MqU1X1QNdMHIjks6wC7XTVf0KNOv5es/Ms6gjVFCAAWTVP2JStuGqydg3DT+ExpFORUEi9yhg==", "dev": true, "dependencies": { - "vue-demi": ">=0.14.5" + "vue-demi": ">=0.14.6" }, "funding": { "url": "https://github.com/sponsors/antfu" @@ -2100,15 +2100,15 @@ } }, "node_modules/eslint": { - "version": "8.50.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.50.0.tgz", - "integrity": "sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==", + "version": "8.51.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", + "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.50.0", + "@eslint/js": "8.51.0", "@humanwhocodes/config-array": "^0.11.11", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -2483,9 +2483,9 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, "node_modules/focus-trap": { - "version": "7.5.2", - "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.5.2.tgz", - "integrity": "sha512-p6vGNNWLDGwJCiEjkSK6oERj/hEyI9ITsSwIUICBoKLlWiTWXJRfQibCwcoi50rTZdbi87qDtUlMCmQwsGSgPw==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.5.4.tgz", + "integrity": "sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==", "dev": true, "dependencies": { "tabbable": "^6.2.0" @@ -3237,9 +3237,9 @@ } }, "node_modules/magic-string": { - "version": "0.30.3", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.3.tgz", - "integrity": "sha512-B7xGbll2fG/VjP+SWg4sX3JynwIU0mjoTc6MPpKNuIvftk6u6vqhDnk1R80b8C2GBR6ywqy+1DcKBrevBg+bmw==", + "version": "0.30.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz", + "integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==", "dev": true, "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" @@ -3981,9 +3981,9 @@ } }, "node_modules/rollup": { - "version": "3.29.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.2.tgz", - "integrity": "sha512-CJouHoZ27v6siztc21eEQGo0kIcE5D1gVPA571ez0mMYb25LGYGKnVNXpEj5MGlepmDWGXNjDB5q7uNiPHC11A==", + "version": "3.29.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", + "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -4054,14 +4054,14 @@ "peer": true }, "node_modules/selenium-webdriver": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.13.0.tgz", - "integrity": "sha512-8JS0h5E0Sq7gNfbGg8LVaQ+Eqek97tvOONn3Jmy+NiWfb12WYpftz4VTC4D2JT4wakdG6VUzGKpA8cFGg0IjkA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.14.0.tgz", + "integrity": "sha512-637rs8anqMKHbWxcBZpyG3Gcs+rBUtAUiqk0O/knUqH4Paj3MFUZrz88/pVGOLNryEVy2z92fZomT8p1ENl1gA==", "dev": true, "dependencies": { "jszip": "^3.10.1", "tmp": "^0.2.1", - "ws": ">=8.13.0" + "ws": ">=8.14.2" }, "engines": { "node": ">= 14.20.0" @@ -4129,9 +4129,9 @@ } }, "node_modules/shiki": { - "version": "0.14.4", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.4.tgz", - "integrity": "sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ==", + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.5.tgz", + "integrity": "sha512-1gCAYOcmCFONmErGTrS1fjzJLA7MGZmKzrBNX7apqSwhyITJg2O102uFzXUeBxNnEkDA9vHIKLyeKq0V083vIw==", "dev": true, "dependencies": { "ansi-sequence-parser": "^1.1.0", @@ -4624,9 +4624,9 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/vite": { - "version": "4.4.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.9.tgz", - "integrity": "sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==", + "version": "4.4.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.11.tgz", + "integrity": "sha512-ksNZJlkcU9b0lBwAGZGGaZHCMqHsc8OpgtoYhsQ4/I2v5cnpmmmqe5pM4nv/4Hn6G/2GhTdj0DhZh2e+Er1q5A==", "dev": true, "dependencies": { "esbuild": "^0.18.10", @@ -4679,22 +4679,22 @@ } }, "node_modules/vitepress": { - "version": "1.0.0-rc.20", - "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-rc.20.tgz", - "integrity": "sha512-CykMUJ8JLxLcGWek0ew3wln4RYbsOd1+0YzXITTpajggpynm2S331TNkJVOkHrMRc6GYe3y4pS40GfgcW0ZwAw==", + "version": "1.0.0-rc.21", + "resolved": "https://registry.npmjs.org/vitepress/-/vitepress-1.0.0-rc.21.tgz", + "integrity": "sha512-eHX057NgAqmrj6FIqh7Sqsbk/kftrFMBUpCKjuQIZ+c+bYTbmzXsXrHSbT5b4WWy4vLx1993a+H3wIRy2dHi8g==", "dev": true, "dependencies": { "@docsearch/css": "^3.5.2", "@docsearch/js": "^3.5.2", - "@types/markdown-it": "^13.0.1", - "@vue/devtools-api": "^6.5.0", - "@vueuse/core": "^10.4.1", - "@vueuse/integrations": "^10.4.1", - "focus-trap": "^7.5.2", + "@types/markdown-it": "^13.0.2", + "@vue/devtools-api": "^6.5.1", + "@vueuse/core": "^10.5.0", + "@vueuse/integrations": "^10.5.0", + "focus-trap": "^7.5.3", "mark.js": "8.11.1", "minisearch": "^6.1.0", - "shiki": "^0.14.4", - "vite": "^4.4.9", + "shiki": "^0.14.5", + "vite": "^4.4.11", "vue": "^3.3.4" }, "bin": { @@ -4702,7 +4702,7 @@ }, "peerDependencies": { "markdown-it-mathjax3": "^4.3.2", - "postcss": "^8.4.30" + "postcss": "^8.4.31" }, "peerDependenciesMeta": { "markdown-it-mathjax3": { @@ -4772,11 +4772,11 @@ } }, "node_modules/winston": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.10.0.tgz", - "integrity": "sha512-nT6SIDaE9B7ZRO0u3UvdrimG0HkB7dSTAgInQnNR2SOPJ4bvq5q79+pXLftKmP52lJGW15+H5MCK0nM9D3KB/g==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.11.0.tgz", + "integrity": "sha512-L3yR6/MzZAOl0DsysUXHVjOwv8mKZ71TrA/41EIduGpOOV5LQVodqN+QdQ6BS6PJ/RdIshZhq84P/fStEZkk7g==", "dependencies": { - "@colors/colors": "1.5.0", + "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.2", "async": "^3.2.3", "is-stream": "^2.0.0", @@ -4818,6 +4818,14 @@ "node": ">= 6" } }, + "node_modules/winston/node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/winston/node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", diff --git a/package.json b/package.json index c76ee9bc8..6b2a2b948 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nw-builder", - "version": "4.4.1", + "version": "4.4.2", "description": "Build NW.js desktop applications for MacOS, Windows and Linux.", "keywords": [ "NW.js", @@ -52,14 +52,14 @@ }, "devDependencies": { "concurrently": "^8.2.1", - "eslint": "^8.50.0", + "eslint": "^8.51.0", "eslint-config-tjw-jsdoc": "^1.0.4", "gh-pages": "^6.0.0", "jsdoc": "^4.0.2", "jsdoc-to-markdown": "^8.0.0", "prettier": "^3.0.3", - "selenium-webdriver": "^4.13.0", - "vitepress": "^1.0.0-rc.20" + "selenium-webdriver": "^4.14.0", + "vitepress": "^1.0.0-rc.21" }, "dependencies": { "cli-progress": "^3.12.0", @@ -67,11 +67,11 @@ "glob": "^10.3.10", "plist": "^3.1.0", "rcedit": "^4.0.0", - "winston": "^3.10.0", + "winston": "^3.11.0", "yargs": "^17.7.2" }, "packageManager": "npm@9.8.1", "engines": { - "node": ">= v16.20.1 || >= v18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.2 || >= 20.8.1" } } diff --git a/src/get.js b/src/get.js index a6c3f9302..d785b1e85 100644 --- a/src/get.js +++ b/src/get.js @@ -9,8 +9,7 @@ import progress from "cli-progress"; import compressing from "compressing"; import { log } from "./log.js"; -import { PLATFORM_KV, ARCH_KV } from "./util.js"; -import { replaceFfmpeg } from "./util/ffmpeg.js"; +import { ARCH_KV, PLATFORM_KV, replaceFfmpeg } from "./util.js"; /** * _Note: This an internal function which is not called directly. Please see example usage below._ @@ -155,7 +154,7 @@ async function get_nwjs({ // Check if cache exists. try { await readdir(nwDir); - log.debug(`Found existing binaries`); + log.debug(`Found existing NW.js binaries`); } catch (error) { log.debug(`No existing binaries`); nwCached = false; @@ -283,37 +282,13 @@ async function get_ffmpeg({ recursive: true, force: true, }); + log.debug(`FFMPEG zip cache removed`); } - const unzipFFMPeg = async () => { - if (platform === "linux") { - await compressing.tgz.uncompress(out, nwDir); - } else { - await compressing.zip.uncompress(out, nwDir); - } - let ffmpegFile; - if (platform === "linux") { - ffmpegFile = "libffmpeg.so"; - } else if (platform === "win") { - ffmpegFile = "ffmpeg.dll"; - } else if (platform === "osx") { - ffmpegFile = "libffmpeg.dylib"; - } - await replaceFfmpeg(platform, nwDir, ffmpegFile); - - if (cache === false) { - log.debug(`Removing FFMPEG zip cache`); - await rm(out, { - recursive: true, - force: true, - }); - log.debug(`FFMPEG zip cache removed`); - } - }; // Check if cache exists. - if (existsSync(out)) { + if (existsSync(out) === true) { log.debug(`Found existing FFMPEG cache`); - await unzipFFMPeg(); + await compressing.zip.uncompress(out, nwDir); return; } @@ -355,5 +330,17 @@ async function get_ffmpeg({ }); // Remove compressed file after download and decompress. - return request.then(unzipFFMPeg); + return request + .then(async () => await compressing.zip.uncompress(out, nwDir)) + .then(async () => await replaceFfmpeg(platform, nwDir)) + .then(async () => { + if (cache === false) { + log.debug(`Removing FFMPEG zip cache`); + await rm(out, { + recursive: true, + force: true, + }); + log.debug(`FFMPEG zip cache removed`); + } + }); } diff --git a/src/util.js b/src/util.js index 37b64a287..a5e3aa7e9 100644 --- a/src/util.js +++ b/src/util.js @@ -1,4 +1,4 @@ -import { readFile, writeFile } from "node:fs/promises"; +import { copyFile, readFile, writeFile } from "node:fs/promises"; import { get } from "node:https"; import { resolve } from "node:path"; @@ -101,3 +101,56 @@ export const EXE_NAME = { osx: "nwjs.app/Contents/MacOS/nwjs", linux: "nw", }; + +/** + * Replaces the ffmpeg file in the nwjs directory with the one provided + * + * @param {string} platform The platform to replace the ffmpeg file for + * @param {string} nwDir The directory of the nwjs installation + */ +export const replaceFfmpeg = async (platform, nwDir) => { + let ffmpegFile; + if (platform === "linux") { + ffmpegFile = "libffmpeg.so"; + } else if (platform === "win") { + ffmpegFile = "ffmpeg.dll"; + } else if (platform === "osx") { + ffmpegFile = "libffmpeg.dylib"; + } + const src = resolve(nwDir, ffmpegFile); + if (platform === "linux") { + const dest = resolve(nwDir, "lib", ffmpegFile); + await copyFile(src, dest); + } else if (platform === "win") { + // don't do anything for windows because the extracted file is already in the correct path + // await copyFile(src, resolve(nwDir, ffmpegFile)); + } else if (platform === "osx") { + let dest = resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Versions", + "Current", + ffmpegFile, + ); + + try { + await copyFile(src, dest); + } catch (e) { + //some versions of node/macOS complain about destination being a file, and others complain when it is only a directory. + //the only thing I can think to do is to try both + dest = resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Versions", + "Current", + ); + await copyFile(src, dest); + } + } +}; diff --git a/src/util/ffmpeg.js b/src/util/ffmpeg.js deleted file mode 100644 index 9d4066774..000000000 --- a/src/util/ffmpeg.js +++ /dev/null @@ -1,48 +0,0 @@ -import { copyFile } from "node:fs/promises"; -import { resolve } from "node:path"; - -/** - * Replaces the ffmpeg file in the nwjs directory with the one provided - * - * @param {string} platform The platform to replace the ffmpeg file for - * @param {string} nwDir The directory of the nwjs installation - * @param {string} ffmpegFile The path to the ffmpeg file to replace with - */ -export const replaceFfmpeg = async (platform, nwDir, ffmpegFile) => { - const src = resolve(nwDir, ffmpegFile); - if (platform === "linux") { - const dest = resolve(nwDir, "lib", ffmpegFile); - await copyFile(src, dest); - } else if (platform === "win") { - // don't do anything for windows because the extracted file is already in the correct path - // await copyFile(src, resolve(nwDir, ffmpegFile)); - } else if (platform === "osx") { - let dest = resolve( - nwDir, - "nwjs.app", - "Contents", - "Frameworks", - "nwjs Framework.framework", - "Versions", - "Current", - ffmpegFile, - ); - - try { - await copyFile(src, dest); - } catch (e) { - //some versions of node/macOS complain about destination being a file, and others complain when it is only a directory. - //the only thing I can think to do is to try both - dest = resolve( - nwDir, - "nwjs.app", - "Contents", - "Frameworks", - "nwjs Framework.framework", - "Versions", - "Current", - ); - await copyFile(src, dest); - } - } -}; diff --git a/test/fixture/demo.js b/test/fixture/demo.js index ae4d3250c..c36e071ed 100644 --- a/test/fixture/demo.js +++ b/test/fixture/demo.js @@ -5,7 +5,6 @@ await nwbuild({ version: "0.80.0", platform: "osx", srcDir: "app", - outDir: "out", glob: false, app: { name: "demo",