Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve npm-scripts #1207

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ async function run()
// TypeScript to JavaScript.
case 'prepare':
{
flatcNode(/* clean */ true);
buildTypescript(/* force */ false);
flatcNode();
buildTypescript({ force: false });

break;
}
Expand Down Expand Up @@ -86,7 +86,11 @@ async function run()
logInfo(`couldn't fetch any mediasoup-worker prebuilt binary, building it locally`);

buildWorker();
cleanWorkerArtifacts();

if (!process.env.MEDIASOUP_LOCAL_DEV)
{
cleanWorkerArtifacts();
}
}

break;
Expand All @@ -95,7 +99,7 @@ async function run()
case 'typescript:build':
{
installNodeDeps();
buildTypescript(/* force */ true);
buildTypescript({ force: true });

break;
}
Expand Down Expand Up @@ -159,7 +163,7 @@ async function run()

case 'test:node':
{
buildTypescript(/* force */ false);
buildTypescript({ force: false });
testNode();

break;
Expand All @@ -174,7 +178,7 @@ async function run()

case 'coverage:node':
{
buildTypescript(/* force */ false);
buildTypescript({ force: false });
executeCmd('jest --coverage');
executeCmd('open-cli coverage/lcov-report/index.html');

Expand Down Expand Up @@ -289,7 +293,7 @@ function deleteNodeLib()
}
}

function buildTypescript(force = false)
function buildTypescript({ force = false } = { force: false })
{
if (!force && fs.existsSync('node/lib'))
{
Expand Down Expand Up @@ -358,7 +362,7 @@ function lintWorker()
executeCmd(`${MAKE} lint -C worker`);
}

function flatcNode(clean = false)
function flatcNode()
{
logInfo('flatcNode()');

Expand All @@ -382,11 +386,6 @@ function flatcNode(clean = false)
{
executeCmd(`for file in ${src}; do ${command} \$\{file\}; done`);
}

if (clean)
{
cleanWorkerArtifacts();
}
}

function flatcWorker()
Expand Down Expand Up @@ -433,7 +432,7 @@ function checkRelease()

installNodeDeps();
flatcNode();
buildTypescript(/* force */ true);
buildTypescript({ force: true });
buildWorker();
lintNode();
lintWorker();
Expand Down
Loading