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

Use ts-jest instead of babel directly / run prettier during github actions / fix prettier issues #434

Merged
merged 5 commits into from
May 29, 2024
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
12 changes: 10 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ jobs:
- uses: ./.github/actions/configure-nodejs
with:
node-version: ${{ matrix.node-version }}
- run: npm run build --if-present
- run: npm run test:full
- name: Lint
run: npm run lint
- name: Check Formatting with Prettier
run: npm run prettier
- name: Build TypeScript
run: npm run build
- name: Unit Tests
run: npm run test
- name: XML Lint Test
run: npm run test:xmllint
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dist
*~

# code coverage
coverage/*
coverage/
.nyc_output/

/yarn.lock
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ webpack.*.config.ts
karma.conf.js
/_config.yml
intellij-style-guide.xml
babel.config.js
urls.txt
stream-write.js
toflat.js
Expand Down
7 changes: 0 additions & 7 deletions babel.config.js

This file was deleted.

10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
/** @type {import('jest').Config} */
const config = {
preset: 'ts-jest',
rootDir: 'tests/',
transform: {
"^.+\\.ts?$": [
"ts-jest",
{
tsconfig: "tsconfig.jest.json",
},
],
},
collectCoverage: true,
collectCoverageFrom: [
'lib/**/*.ts',
Expand Down
22 changes: 21 additions & 1 deletion lib/xmllint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
import { existsSync } from 'fs';
import { Readable } from 'stream';
import { resolve } from 'path';
import { execFile } from 'child_process';
import { XMLLintUnavailable } from './errors';

/**
* Finds the `schema` directory since we may be located in
* `lib` or `dist/lib` when this is called.
*
* @throws {Error} if the schema directory is not found
* @returns {string} the path to the schema directory
*/
function findSchemaDir(): string {
const paths = ['.', '..', '../..'];
for (const p of paths) {
const schemaPath = resolve(p, 'schema');
if (existsSync(schemaPath)) {
return schemaPath;
}
}
throw new Error('Schema directory not found');
}

/**
* Verify the passed in xml is valid. Requires xmllib be installed
* @param xml what you want validated
Expand All @@ -10,7 +30,7 @@ import { XMLLintUnavailable } from './errors';
export function xmlLint(xml: string | Readable): Promise<void> {
const args = [
'--schema',
resolve(__dirname, '..', '..', 'schema', 'all.xsd'),
resolve(findSchemaDir(), 'all.xsd'),
'--noout',
'-',
];
Expand Down
Loading