Skip to content

Commit

Permalink
fix: copy ffmpeg to correct path after extract (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrige authored Aug 11, 2023
1 parent 169897d commit 675ca68
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [4.3.7] - 2023-08-11

### Changed

- Move community `ffmpeg` in the correct folder.

## [4.3.6] - 2023-08-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nw-builder",
"version": "4.3.6",
"version": "4.3.7",
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
"keywords": [
"NW.js",
Expand Down
10 changes: 9 additions & 1 deletion src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,15 @@ export async function get({
// Remove compressed file after download and decompress.
return request.then(async () => {
if (ffmpeg === true) {
await replaceFfmpeg(platform, nwDir, out);
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);
}

log.debug(`Binary decompressed starting removal`);
Expand Down
27 changes: 15 additions & 12 deletions src/util/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ import { resolve } from "node:path";
* @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") {
await copyFile(ffmpegFile, resolve(nwDir, "lib", ffmpegFile));
const dest = resolve(nwDir, "lib", ffmpegFile);
await copyFile(src, dest);
} else if (platform === "win") {
await copyFile(ffmpegFile, resolve(nwDir, ffmpegFile));
// 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") {
await copyFile(
const dest = resolve(
nwDir,
"nwjs.app",
"Contents",
"Frameworks",
"nwjs Framework.framework",
"Versions",
"Current",
ffmpegFile,
resolve(
nwDir,
"Contents",
"Frameworks",
"nwjs Framework.framework",
"Versions",
"Current",
ffmpegFile,
),
);

await copyFile(src, dest);
}
};

0 comments on commit 675ca68

Please sign in to comment.