Skip to content

Commit

Permalink
Merge branch 'main' into improve-enumToMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Jan 30, 2024
2 parents 5a20f05 + a930586 commit 506e4e6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ jobs:

# Custom script, because progress looks not good in CI
- name: Run tests
env:
CFLAGS: -O0
run: npx mocha --timeout 30000 -r ts-node/register/type-check test/*-test.ts
run: npm run test

lint:
name: Run ESLint
Expand Down
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
5 changes: 3 additions & 2 deletions docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ These are the required steps to release a new version of llhttp:

First of all, make sure you have [GitHub CLI](https://cli.github.com) installed and configured. While this is not strictly necessary, it will make your life way easier.

As a preliminary check, run the build command and execute the test suite locally:
As a preliminary check, lint the code, run the build command and execute the test suite locally:

```
npm run lint
npm run build
npm test
npm run test
```

If all goes good, you are ready to go!
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"wasm": "ts-node bin/build_wasm.ts",
"clean": "rm -rf lib && rm -rf test/tmp",
"prepare": "npm run clean && npm run build-ts",
"test": "node -r ts-node/register/type-check --test ./test/*-test.ts",
"lint": "eslint -c eslint.json bin/*.ts src/*.ts src/**/*.ts test/*.ts test/**/*.ts",
"lint-fix": "eslint --fix -c eslint.json bin/*.ts src/*.ts src/**/*.ts test/*.ts test/**/*.ts",
"mocha": "mocha --timeout=10000 -r ts-node/register/type-check --reporter progress test/*-test.ts",
"test": "npm run mocha && npm run lint",
"postversion": "RELEASE=`node -e \"process.stdout.write(require('./package').version)\"` make -B postversion",
"github-release": "RELEASE_V=`node -e \"process.stdout.write('v' + require('./package').version)\"` make github-release"
},
Expand All @@ -42,15 +42,13 @@
"homepage": "https://github.com/nodejs/llhttp#readme",
"devDependencies": {
"@stylistic/eslint-plugin": "^1.5.4",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.10",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"llparse-dot": "^1.0.1",
"llparse-test-fixture": "^5.0.1",
"mdgator": "^1.1.2",
"mocha": "^10.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
Expand Down
7 changes: 3 additions & 4 deletions test/md-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as assert from 'assert';
import * as assert from 'node:assert';
import { describe, test } from 'node:test';
import * as fs from 'fs';
import { LLParse } from 'llparse';
import { Group, MDGator, Metadata, Test } from 'mdgator';
Expand Down Expand Up @@ -92,7 +93,7 @@ function run(name: string): void {
function runSingleTest(ty: TestType, meta: Metadata,
input: string,
expected: ReadonlyArray<string | RegExp>): void {
it(`should pass for type="${ty}"`, async () => {
test(`should pass for type="${ty}"`, { timeout: 60000 }, async () => {
const binary = await buildMode(ty, meta);
await binary.check(input, expected, {
noScan: meta.noScan === true,
Expand Down Expand Up @@ -208,8 +209,6 @@ function run(name: string): void {

function runGroup(group: Group) {
describe(group.name + ` at ${name}.md:${group.line + 1}`, function () {
this.timeout(60000);

for (const child of group.children) {
runGroup(child);
}
Expand Down

0 comments on commit 506e4e6

Please sign in to comment.