Skip to content
Open
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
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- node: 24
os: ubuntu-latest
steps:
- name: Harden the runner # Inspired by https://github.com/dominikg/tsconfck
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
release-assets.githubusercontent.com:443
registry.npmjs.org:443

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: 'false'

- name: Setup Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm i

- name: Build
run: npm run build

- name: Lint
if: ${{ !cancelled() }}
run: npm run lint

- name: Test with coverage
if: ${{ !cancelled() }}
run: npm run test-cov

- name: Test specs
if: ${{ !cancelled() }}
run: npm run test-spec
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"strip-json-comments": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/chai": " ~4.0.4",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.25",
"@types/node": "~8.0.25",
"bluebird": "^3.4.1",
"chai": "^3.0.0",
"istanbul": "^0.4.0",
Expand Down
13 changes: 12 additions & 1 deletion src/tsconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ interface Test {
}

describe('tsconfig', function () {

const nodeMajor = Number(process.version.match(/v(\d+)/)[1])
let invalidJsonError
if (nodeMajor >= 20) {
invalidJsonError = "Unexpected token 's', \"some random string\" is not valid JSON"
} else if (nodeMajor >= 6) {
invalidJsonError = 'Unexpected token s in JSON at position 0'
} else {
invalidJsonError = 'Unexpected token s'
}

const tests: Test[] = [
{
args: [TEST_DIR, 'invalidfile'],
error: parseInt(process.versions.node, 10) > 5 ? 'Unexpected token s in JSON at position 0' : 'Unexpected token s'
error: invalidJsonError
},
{
args: [TEST_DIR, 'missing'],
Expand Down