Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions bin/build_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if (process.argv[2] === '--setup') {
try {
mkdirSync(join(WASM_SRC, 'build'));
process.exit(0);
} catch (error) {
if (error.code !== 'EEXIST') {
} catch (error: unknown) {
if (isErrorWithCode(error) && error.code !== 'EEXIST') {
throw error;
}
process.exit(0);
Expand All @@ -39,7 +39,7 @@ if (process.argv[2] === '--docker') {
// It will work flawessly if uid === gid === 1000
// there will be some warnings otherwise.
if (process.platform === 'linux') {
cmd += ` --user ${process.getuid()}:${process.getegid()}`;
cmd += ` --user ${process.getuid!()}:${process.getegid!()}`;
}
cmd += ` --mount type=bind,source=${WASM_SRC}/build,target=/home/node/llhttp/build llhttp_wasm_builder npm run wasm`;

Expand All @@ -51,8 +51,8 @@ if (process.argv[2] === '--docker') {

try {
mkdirSync(WASM_OUT);
} catch (error) {
if (error.code !== 'EEXIST') {
} catch (error: unknown) {
if (isErrorWithCode(error) && error.code !== 'EEXIST') {
throw error;
}
}
Expand Down Expand Up @@ -93,3 +93,7 @@ copyFileSync(join(WASM_SRC, 'lib', 'llhttp', 'constants.d.ts'), join(WASM_OUT, '
copyFileSync(join(WASM_SRC, 'lib', 'llhttp', 'utils.js'), join(WASM_OUT, 'utils.js'));
copyFileSync(join(WASM_SRC, 'lib', 'llhttp', 'utils.js.map'), join(WASM_OUT, 'utils.js.map'));
copyFileSync(join(WASM_SRC, 'lib', 'llhttp', 'utils.d.ts'), join(WASM_OUT, 'utils.d.ts'));

function isErrorWithCode(error: unknown): error is Error & { code: string } {
return typeof error === 'object' && error !== null && 'code' in error;
}
3 changes: 2 additions & 1 deletion bin/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { dirname, resolve } from 'path';
import { CHeaders, HTTP } from '../src/llhttp';

// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
const semverRE = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
// eslint-disable-next-line max-len
const semverRE = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;

const C_FILE = resolve(__dirname, '../build/c/llhttp.c');
const HEADER_FILE = resolve(__dirname, '../build/llhttp.h');
Expand Down