Skip to content

Commit 5bf9868

Browse files
authored
Add support for bun (#4)
1 parent 1558033 commit 5bf9868

File tree

17 files changed

+2543
-4871
lines changed

17 files changed

+2543
-4871
lines changed

.github/workflows/ci-bun.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Bun.js
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: oven-sh/setup-bun@v1
12+
- run: bun install
13+
- run: bun run check
14+
- run: bun test --coverage
15+
- run: bun run build
16+
- uses: codecov/codecov-action@v1
17+
with:
18+
name: Bun.js
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
- pull_request
55
jobs:
66
test:
7+
env:
8+
BIN_EXEC: tsx
79
name: Node.js ${{ matrix.node-version }}
810
runs-on: ubuntu-latest
911
strategy:
@@ -12,7 +14,7 @@ jobs:
1214
- "14"
1315
- "*"
1416
steps:
15-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1618
- uses: actions/setup-node@v1
1719
with:
1820
node-version: ${{ matrix.node-version }}
@@ -22,9 +24,10 @@ jobs:
2224
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
2325
restore-keys: |
2426
${{ runner.os }}-node-
25-
- run: npm install -g npm@7
2627
- run: npm ci
27-
- run: npm test
28+
- run: npm run check
29+
- run: npm run specs --coverage
30+
- run: npm run build
2831
- uses: codecov/codecov-action@v1
2932
with:
3033
name: Node.js ${{ matrix.node-version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ coverage/
44
npm-debug.log
55
dist/
66
dist.es2015/
7+
bun.lockb

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ In your `package.json` you can use the scripts:
2020
```json
2121
{
2222
"scripts": {
23-
"lint": "ts-scripts lint",
2423
"format": "ts-scripts format",
2524
"specs": "ts-scripts specs",
26-
"test": "ts-scripts test",
25+
"test": "ts-scripts test", // Runs `check`, `specs --coverage`, `build`.
2726
"build": "ts-scripts build",
2827
"prepublishOnly": "npm run build",
2928
"prepare": "ts-scripts install"
3029
}
3130
}
3231
```
3332

34-
You will also need to install `typescript` for building and `vitest` for testing.
33+
You will also need to install `typescript` for building and `vitest` for specs.
34+
35+
**Note:** If using `bun`, you don't need `vitest`. You can use `bun test` instead.
3536

3637
### Batteries Included
3738

3839
- `install` - Installs `husky` and `lint-staged` for git commit hooks
39-
- `lint` - Uses `eslint --fix` on all supported files in `src` (i.e. `js`, `jsx`, `ts`, `tsx`)
4040
- `format` - Uses `prettier --write` on all supported files in `src` and the root directory
4141
- `specs` - Uses `vitest` to run test files match `*.{test,spec}.*` files
4242
- `--watch <index>` Runs vitest in watch mode on the config at `<index>`
@@ -45,15 +45,15 @@ You will also need to install `typescript` for building and `vitest` for testing
4545
- `--since <commit>` Runs tests on files changed since `<commit>`
4646
- `--test-pattern` Runs tests matching the specified pattern
4747
- `build` - Uses `rimraf` and `tsc`
48-
- `check` - Uses `eslint`, `prettier --check`, and `tsc` on each test "project"
48+
- `check` - Uses `prettier --check` and `tsc` on each test "project"
4949
- `test` - Runs `check`, `specs`, and `build`
5050

5151
### Configuration
5252

5353
Configuration can get specified in your `package.json` file under `ts-scripts`:
5454

55-
- `src` - An array of source directories used for `format` and `lint` (default: `["src"]`)
56-
- `ignore` - An array of patterns to ignore for `format` and `lint` (default: `[]`)
55+
- `src` - An array of source file directories (default: `["src"]`)
56+
- `ignore` - An array of patterns to ignore (default: `[]`)
5757
- `dist` - An array of output directories to clean before `build` (default: `["dist"]`)
5858
- `project` An array of TSConfig files to build using TypeScript (default: `["tsconfig.json"]`)
5959
- `checkProject` An array of TSConfig files to type check using TypeScript (default: `["tsconfig.json"]`)

configs/eslint.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

configs/husky/bun/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
bun "$(dirname "$0")/../../../dist/bin.js" pre-commit

configs/husky/node/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
node "$(dirname "$0")/../../../dist/bin.js" pre-commit

configs/husky/pre-commit

Lines changed: 0 additions & 4 deletions
This file was deleted.

configs/lint-staged.cjs

Lines changed: 0 additions & 6 deletions
This file was deleted.

configs/lint-staged.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const script = `${process.argv0} '${require.resolve("../dist/bin.js")}'`;
2+
3+
const config = {
4+
[process.env.TS_SCRIPTS_FORMAT_GLOB]: `${script} format`,
5+
};
6+
7+
export default config;

0 commit comments

Comments
 (0)