Skip to content

Commit 8d70539

Browse files
committed
fix: use CommonJS syntax for JavaScript path, add CI workflow
- Config file uses module.exports instead of export default for JS - Test file uses require() instead of import for JS - Add GitHub Actions workflow for build and npm publish on tag
1 parent 6a9bc14 commit 8d70539

2 files changed

Lines changed: 63 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build
2+
permissions:
3+
id-token: write
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
tags:
11+
- "*.*.*"
12+
pull_request:
13+
branches:
14+
- main
15+
16+
jobs:
17+
build:
18+
permissions:
19+
id-token: write
20+
contents: read
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v5
26+
27+
- name: Use Node.js 24
28+
uses: actions/setup-node@v5
29+
with:
30+
node-version: '24'
31+
registry-url: 'https://registry.npmjs.org'
32+
33+
- name: Install dependencies
34+
run: npm ci --ignore-scripts
35+
36+
- name: Audit
37+
run: npm audit --audit-level high --omit dev
38+
39+
- name: Update version
40+
if: github.ref_type == 'tag'
41+
env:
42+
VERSION: ${{ github.ref_name }}
43+
run: |
44+
npm version "$VERSION" --no-git-tag-version
45+
46+
- name: Build
47+
run: |
48+
npm run build
49+
50+
- name: Publish
51+
if: github.ref_type == 'tag'
52+
run: |
53+
npm publish --access public --provenance

src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ function createConfigFile(targetDir: string, testDir: string, language: Language
4040
? `import { defineConfig } from '@mobilewright/test';\n`
4141
: `const { defineConfig } = require('@mobilewright/test');\n`;
4242

43+
const exportLine = language === "ts"
44+
? "export default defineConfig"
45+
: "module.exports = defineConfig";
46+
4347
const content = `${importLine}
44-
export default defineConfig({
48+
${exportLine}({
4549
testDir: './${testDir}',
4650
reporter: 'html',
4751
});
@@ -54,7 +58,11 @@ function createTestFile(targetDir: string, testDir: string, language: Language):
5458
const ext = language === "ts" ? "ts" : "js";
5559
const fullTestDir = path.join(targetDir, testDir);
5660
fs.mkdirSync(fullTestDir, { recursive: true });
57-
const content = `import { test, expect } from '@mobilewright/test';
61+
const importLine = language === "ts"
62+
? `import { test, expect } from '@mobilewright/test';`
63+
: `const { test, expect } = require('@mobilewright/test');`;
64+
65+
const content = `${importLine}
5866
5967
test.use({ bundleId: "com.example.app" });
6068

0 commit comments

Comments
 (0)