Skip to content

Commit

Permalink
Allow mediasoup installation under path with whitespaces (fixes #753)
Browse files Browse the repository at this point in the history
# Conflicts:
#	npm-scripts.mjs
  • Loading branch information
ibc committed Nov 26, 2023
1 parent d5254a4 commit c7720f2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 63 deletions.
40 changes: 20 additions & 20 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async function run()

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

break;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ function installInvoke()
// Install pip invoke into custom location, so we don't depend on system-wide
// installation.
executeCmd(
`${PYTHON} -m pip install --upgrade --target=${PIP_INVOKE_DIR} invoke==${INVOKE_VERSION}`, /* exitOnError */ true
`"${PYTHON}" -m pip install --upgrade --target="${PIP_INVOKE_DIR}" invoke==${INVOKE_VERSION}`, /* exitOnError */ true
);
}

Expand Down Expand Up @@ -366,19 +366,19 @@ function buildWorker()
{
logInfo('buildWorker()');

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

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

// 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.
executeCmd(`${PYTHON} -m invoke -r worker clean-subprojects`);
executeCmd(`"${PYTHON}" -m invoke -r worker clean-subprojects`);
// Clean PIP/Meson/Ninja.
executeCmd(`${PYTHON} -m invoke -r worker clean-pip`);
executeCmd(`"${PYTHON}" -m invoke -r worker clean-pip`);
}

function lintNode()
Expand All @@ -392,40 +392,40 @@ function lintWorker()
{
logInfo('lintWorker()');

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

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

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

const buildType = process.env.MEDIASOUP_BUILDTYPE || 'Release';
const extension = IS_WINDOWS ? '.exe' : '';
const flatc = path.resolve(path.join(
'worker', 'out', buildType, 'build', 'subprojects', `flatbuffers-${FLATBUFFERS_VERSION}`, `flatc${extension}`));
const src = path.resolve(path.join('worker', 'fbs', '*.fbs'));
const out = path.resolve(path.join('node', 'src'));
const options = '--ts-no-import-ext --gen-object-api';
const command = `${flatc} --ts ${options} -o ${out} `;

if (IS_WINDOWS)
for (const dirent of fs.readdirSync(path.join('worker', 'fbs'), { withFileTypes: true }))
{
executeCmd(`for %f in (${src}) do ${command} %f`);
}
else
{
executeCmd(`for file in ${src}; do ${command} \$\{file\}; done`);
if (!dirent.isFile() || path.parse(dirent.name).ext !== '.fbs')
{
continue;
}

const filePath = path.resolve(path.join('worker', 'fbs', dirent.name));

executeCmd(`"${flatc}" --ts --ts-no-import-ext --gen-object-api -o "${out}" "${filePath}"`);
}
}

function flatcWorker()
{
logInfo('flatcWorker()');

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

function testNode()
Expand All @@ -438,15 +438,15 @@ function testNode()
}
else
{
executeCmd(`jest --testPathPattern ${process.env.TEST_FILE}`);
executeCmd(`jest --testPathPattern "${process.env.TEST_FILE}"`);
}
}

function testWorker()
{
logInfo('testWorker()');

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

function installNodeDeps()
Expand Down
2 changes: 1 addition & 1 deletion worker/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn main() {
.arg("pip")
.arg("install")
.arg("--upgrade")
.arg(format!("--target={pip_invoke_dir}"))
.arg(format!("--target=\"{pip_invoke_dir}\""))
.arg(format!("invoke=={invoke_version}"))
.spawn()
.expect("Failed to start")
Expand Down
4 changes: 2 additions & 2 deletions worker/scripts/clang-format.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function run()
case 'lint':
{
executeCmd(
`${clangFormatNativeBinary} --Werror --dry-run ${workerFiles.join(' ')}`
`"${clangFormatNativeBinary}" --Werror --dry-run ${workerFiles.join(' ')}`
);

break;
Expand All @@ -34,7 +34,7 @@ async function run()
case 'format':
{
executeCmd(
`${clangFormatNativeBinary} --Werror -i ${workerFiles.join(' ')}`
`"${clangFormatNativeBinary}" --Werror -i ${workerFiles.join(' ')}`
);

break;
Expand Down
Loading

0 comments on commit c7720f2

Please sign in to comment.