Skip to content

Commit

Permalink
Merge pull request #434 from huntharo/ts-jest
Browse files Browse the repository at this point in the history
Use ts-jest instead of babel directly / run prettier during github actions / fix prettier issues
  • Loading branch information
derduher authored May 29, 2024
2 parents 2532def + 00fdb77 commit 76f85f4
Show file tree
Hide file tree
Showing 20 changed files with 331 additions and 1,736 deletions.
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

0 comments on commit 76f85f4

Please sign in to comment.