Unverified 提交 bc55f22c authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

npm installation: Don't require Python if valid worker prebuilt binary is fetched (#1265)

上级 fb83d4f4
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
### NEXT ### 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 ### 3.13.11
......
...@@ -47,13 +47,6 @@ async function run() ...@@ -47,13 +47,6 @@ async function run()
{ {
switch (task) switch (task)
{ {
case 'preinstall':
{
installInvoke();
break;
}
// As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts) // As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts)
// `prepare` script: // `prepare` script:
// //
...@@ -167,6 +160,8 @@ async function run() ...@@ -167,6 +160,8 @@ async function run()
case 'format:worker': case 'format:worker':
{ {
installInvoke();
executeCmd(`"${PYTHON}" -m invoke -r worker format`); executeCmd(`"${PYTHON}" -m invoke -r worker format`);
break; break;
...@@ -351,6 +346,8 @@ function buildWorker() ...@@ -351,6 +346,8 @@ function buildWorker()
{ {
logInfo('buildWorker()'); logInfo('buildWorker()');
installInvoke();
executeCmd(`"${PYTHON}" -m invoke -r worker mediasoup-worker`); executeCmd(`"${PYTHON}" -m invoke -r worker mediasoup-worker`);
} }
...@@ -358,6 +355,8 @@ function cleanWorkerArtifacts() ...@@ -358,6 +355,8 @@ function cleanWorkerArtifacts()
{ {
logInfo('cleanWorkerArtifacts()'); logInfo('cleanWorkerArtifacts()');
installInvoke();
// Clean build artifacts except `mediasoup-worker`. // Clean build artifacts except `mediasoup-worker`.
executeCmd(`"${PYTHON}" -m invoke -r worker clean-build`); executeCmd(`"${PYTHON}" -m invoke -r worker clean-build`);
// Clean downloaded dependencies. // Clean downloaded dependencies.
...@@ -377,6 +376,8 @@ function lintWorker() ...@@ -377,6 +376,8 @@ function lintWorker()
{ {
logInfo('lintWorker()'); logInfo('lintWorker()');
installInvoke();
executeCmd(`"${PYTHON}" -m invoke -r worker lint`); executeCmd(`"${PYTHON}" -m invoke -r worker lint`);
} }
...@@ -384,6 +385,8 @@ function flatcNode() ...@@ -384,6 +385,8 @@ function flatcNode()
{ {
logInfo('flatcNode()'); logInfo('flatcNode()');
installInvoke();
// Build flatc if needed. // Build flatc if needed.
executeCmd(`"${PYTHON}" -m invoke -r worker flatc`); executeCmd(`"${PYTHON}" -m invoke -r worker flatc`);
...@@ -410,6 +413,8 @@ function flatcWorker() ...@@ -410,6 +413,8 @@ function flatcWorker()
{ {
logInfo('flatcWorker()'); logInfo('flatcWorker()');
installInvoke();
executeCmd(`"${PYTHON}" -m invoke -r worker flatc`); executeCmd(`"${PYTHON}" -m invoke -r worker flatc`);
} }
...@@ -431,6 +436,8 @@ function testWorker() ...@@ -431,6 +436,8 @@ function testWorker()
{ {
logInfo('testWorker()'); logInfo('testWorker()');
installInvoke();
executeCmd(`"${PYTHON}" -m invoke -r worker test`); executeCmd(`"${PYTHON}" -m invoke -r worker test`);
} }
...@@ -575,6 +582,8 @@ async function downloadPrebuiltWorker() ...@@ -575,6 +582,8 @@ async function downloadPrebuiltWorker()
{ {
const resolvedBinPath = path.resolve(WORKER_RELEASE_BIN_PATH); 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( execSync(
`"${resolvedBinPath}"`, `"${resolvedBinPath}"`,
{ {
...@@ -583,15 +592,15 @@ async function downloadPrebuiltWorker() ...@@ -583,15 +592,15 @@ async function downloadPrebuiltWorker()
env : {} env : {}
} }
); );
logInfo(
'downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary is valid for current host'
);
} }
catch (error) catch (error)
{ {
if (error.status === 41) if (error.status === 41)
{ {
logInfo(
'downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary is valid for current host'
);
resolve(true); resolve(true);
} }
else else
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
"nodejs" "nodejs"
], ],
"scripts": { "scripts": {
"preinstall": "node npm-scripts.mjs preinstall",
"prepare": "node npm-scripts.mjs prepare", "prepare": "node npm-scripts.mjs prepare",
"postinstall": "node npm-scripts.mjs postinstall", "postinstall": "node npm-scripts.mjs postinstall",
"typescript:build": "node npm-scripts.mjs typescript:build", "typescript:build": "node npm-scripts.mjs typescript:build",
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论