Skip to content

Commit c319729

Browse files
committed
chore: add tests, gh actions and prettier config
1 parent 4e7820e commit c319729

16 files changed

Lines changed: 1827 additions & 13 deletions

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
on:
3+
workflow_run:
4+
workflows:
5+
- 'Test'
6+
branches:
7+
- main
8+
types:
9+
- completed
10+
11+
permissions:
12+
contents: read # for checkout
13+
14+
jobs:
15+
release:
16+
name: Release
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write # to be able to publish a GitHub release
20+
issues: write # to be able to comment on released issues
21+
pull-requests: write # to be able to comment on released pull requests
22+
id-token: write # to enable use of OIDC for npm provenance
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 'lts/*'
33+
- name: Install dependencies
34+
run: npm clean-install
35+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
36+
run: npm audit signatures
37+
- name: Release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41+
run: npx semantic-release

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- '**'
6+
7+
permissions:
8+
contents: read # for checkout
9+
10+
jobs:
11+
test:
12+
name: Test
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 'lts/*'
23+
- name: Install bare runtime
24+
run: npm install -g bare
25+
- name: Install dependencies
26+
run: npm clean-install
27+
- name: Run tests
28+
run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ dist
142142
.svelte-kit
143143

144144
# End of https://www.toptal.com/developers/gitignore/api/node
145+
*.bundle

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
const babel = require("@babel/core");
1+
const babel = require('@babel/core')
22

33
async function plugin(bundle, { name, data, mode }) {
44
return new Promise((resolve, reject) => {
55
// only transform javascript files
66
if (name.match(/\.js$|\.cjs$|\.mjs$/)) {
77
babel.transform(data.toString(), (err, result) => {
8-
if (err) reject(err);
8+
if (err) reject(err)
99
// overwrite the old code with the transpiled code in the bundle
10-
bundle.write(name, result.code, { mode });
11-
resolve();
12-
});
10+
bundle.write(name, result.code, { mode })
11+
resolve()
12+
})
1313
} else {
14-
resolve();
14+
resolve()
1515
}
16-
});
16+
})
1717
}
1818

19-
module.exports = plugin;
19+
module.exports = plugin

0 commit comments

Comments
 (0)