From 9b91bee0e405801a03a7c8d2d5a4a6e409d19dad Mon Sep 17 00:00:00 2001 From: William Killerud Date: Fri, 12 Jul 2024 11:31:58 +0200 Subject: [PATCH] refactor: replace shell script with node for type fixup --- .github/workflows/test.yml | 6 ------ fixup.js | 12 ++++++++++++ fixup.sh | 2 -- package.json | 4 +++- 4 files changed, 15 insertions(+), 9 deletions(-) create mode 100755 fixup.js delete mode 100755 fixup.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47e0bfa..b161649 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,13 +31,7 @@ jobs: run: npm run lint - name: npm types - if: runner.os != 'Windows' # because of ./fixup.sh run: npm run types - name: npm test - if: runner.os != 'Windows' run: npm test - - - name: npm test - if: runner.os == 'Windows' - run: npm run test:unit diff --git a/fixup.js b/fixup.js new file mode 100755 index 0000000..f5f317b --- /dev/null +++ b/fixup.js @@ -0,0 +1,12 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +let podium = path.join(process.cwd(), 'types', 'podium.d.ts'); +let module = path.join(process.cwd(), 'types', 'layout-plugin.d.ts'); + +fs.writeFileSync( + module, + `${fs.readFileSync(podium, 'utf-8')} +${fs.readFileSync(module, 'utf-8')}`, + 'utf-8', +); diff --git a/fixup.sh b/fixup.sh deleted file mode 100755 index 4837acf..0000000 --- a/fixup.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -cat >> types/layout-plugin.d.ts < types/podium.d.ts diff --git a/package.json b/package.json index d10c838..3a40bfc 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "test:unit": "tap --disable-coverage --allow-empty-coverage", "test:types": "tsc --project tsconfig.test.json", "test:coverage": "tap", - "types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh" + "types": "run-s types:tsc types:fixup", + "types:tsc": "tsc --declaration --emitDeclarationOnly", + "types:fixup": "node ./fixup.js" }, "author": "Trygve Lie", "dependencies": {