Skip to content

Commit

Permalink
npm installation: Don't require Python if valid worker prebuilt binar…
Browse files Browse the repository at this point in the history
…y is fetched (#1265)
  • Loading branch information
ibc authored Dec 14, 2023
1 parent fb83d4f commit bc55f22
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

### NEXT

* worker: Disable RtcLogger usage if not enabled ([PR #1264](https://github.com/versatica/mediasoup/pull/1264)).
* worker: Disable `RtcLogger` usage if not enabled ([PR #1264](https://github.com/versatica/mediasoup/pull/1264)).
* npm installation: Don't require Python if valid worker prebuilt binary is fetched ([PR #1265](https://github.com/versatica/mediasoup/pull/1265)).


### 3.13.11
Expand Down
31 changes: 20 additions & 11 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ async function run()
{
switch (task)
{
case 'preinstall':
{
installInvoke();

break;
}

// As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts)
// `prepare` script:
//
Expand Down Expand Up @@ -167,6 +160,8 @@ async function run()

case 'format:worker':
{
installInvoke();

executeCmd(`"${PYTHON}" -m invoke -r worker format`);

break;
Expand Down Expand Up @@ -351,13 +346,17 @@ function buildWorker()
{
logInfo('buildWorker()');

installInvoke();

executeCmd(`"${PYTHON}" -m invoke -r worker mediasoup-worker`);
}

function cleanWorkerArtifacts()
{
logInfo('cleanWorkerArtifacts()');

installInvoke();

// Clean build artifacts except `mediasoup-worker`.
executeCmd(`"${PYTHON}" -m invoke -r worker clean-build`);
// Clean downloaded dependencies.
Expand All @@ -377,13 +376,17 @@ function lintWorker()
{
logInfo('lintWorker()');

installInvoke();

executeCmd(`"${PYTHON}" -m invoke -r worker lint`);
}

function flatcNode()
{
logInfo('flatcNode()');

installInvoke();

// Build flatc if needed.
executeCmd(`"${PYTHON}" -m invoke -r worker flatc`);

Expand All @@ -410,6 +413,8 @@ function flatcWorker()
{
logInfo('flatcWorker()');

installInvoke();

executeCmd(`"${PYTHON}" -m invoke -r worker flatc`);
}

Expand All @@ -431,6 +436,8 @@ function testWorker()
{
logInfo('testWorker()');

installInvoke();

executeCmd(`"${PYTHON}" -m invoke -r worker test`);
}

Expand Down Expand Up @@ -575,6 +582,8 @@ async function downloadPrebuiltWorker()
{
const resolvedBinPath = path.resolve(WORKER_RELEASE_BIN_PATH);

// This will always fail on purpose, but if status code is 41 then
// it's good.
execSync(
`"${resolvedBinPath}"`,
{
Expand All @@ -583,15 +592,15 @@ async function downloadPrebuiltWorker()
env : {}
}
);

logInfo(
'downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary is valid for current host'
);
}
catch (error)
{
if (error.status === 41)
{
logInfo(
'downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary is valid for current host'
);

resolve(true);
}
else
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"nodejs"
],
"scripts": {
"preinstall": "node npm-scripts.mjs preinstall",
"prepare": "node npm-scripts.mjs prepare",
"postinstall": "node npm-scripts.mjs postinstall",
"typescript:build": "node npm-scripts.mjs typescript:build",
Expand Down

0 comments on commit bc55f22

Please sign in to comment.