Skip to content

Commit 314032a

Browse files
committed
address pr comments and test failure
1 parent 873d057 commit 314032a

File tree

3 files changed

+92
-19
lines changed

3 files changed

+92
-19
lines changed

.github/workflows/npm-publish.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,67 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
- uses: actions/setup-node@v3
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v3
1315
with:
1416
node-version: '18.x'
1517
registry-url: 'https://registry.npmjs.org'
1618

19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v2
21+
with:
22+
version: 8
23+
run_install: false
24+
25+
- name: Get pnpm store directory
26+
id: pnpm-cache
27+
shell: bash
28+
run: |
29+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
30+
31+
- name: Setup pnpm cache
32+
uses: actions/cache@v3
33+
with:
34+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
1739
- name: Install dependencies
18-
run: npm ci
40+
run: pnpm install
1941

2042
- name: Build
21-
run: npm run build
43+
run: pnpm run build
2244

2345
- name: Run tests
24-
run: npm test -- --no-watch
46+
run: pnpm test -- --no-watch
2547

2648
publish-npm:
2749
needs: build
2850
runs-on: ubuntu-latest
2951
steps:
3052
- uses: actions/checkout@v3
31-
- uses: actions/setup-node@v3
53+
54+
- name: Setup Node.js
55+
uses: actions/setup-node@v3
3256
with:
3357
node-version: '18.x'
3458
registry-url: 'https://registry.npmjs.org'
3559

60+
- name: Setup pnpm
61+
uses: pnpm/action-setup@v2
62+
with:
63+
version: 8
64+
run_install: false
65+
3666
- name: Install dependencies
37-
run: npm ci
67+
run: pnpm install
3868

3969
- name: Build
40-
run: npm run build
70+
run: pnpm run build
4171

4272
- name: Publish to NPM
43-
run: npm publish
73+
run: pnpm publish --no-git-checks
4474
env:
4575
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.github/workflows/unit-tests.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,35 @@ jobs:
1616
uses: actions/setup-node@v3
1717
with:
1818
node-version: '18.x'
19-
cache: 'npm'
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@v2
22+
with:
23+
version: 8
24+
run_install: false
25+
26+
- name: Get pnpm store directory
27+
id: pnpm-cache
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
32+
- name: Setup pnpm cache
33+
uses: actions/cache@v3
34+
with:
35+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
2039
2140
- name: Install dependencies
22-
run: npm ci
41+
run: pnpm install
2342

2443
- name: Run linting
25-
run: npm run lint
44+
run: pnpm run lint
2645

2746
- name: Run unit tests
28-
run: npm test -- --no-watch
47+
run: pnpm test -- --no-watch
2948

3049
- name: Build
31-
run: npm run build
50+
run: pnpm run build

prepend-shebang.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
const shebang = '#!/usr/bin/env node\n';
5-
const files = ['o2f-server.js', 'o2f-client.js'];
4+
const nodeShebang = '#!/usr/bin/env node\n';
5+
const shFiles = '#!/usr/bin/env sh\n';
6+
7+
// Node.js files
8+
const jsFiles = ['o2f-server.js', 'o2f-client.js'];
69
const distPath = path.join(__dirname, 'dist');
710

8-
files.forEach(file => {
11+
// Handle JS files
12+
jsFiles.forEach(file => {
913
const filePath = path.join(distPath, file);
1014

1115
if (fs.existsSync(filePath)) {
@@ -14,9 +18,9 @@ files.forEach(file => {
1418

1519
// Check if shebang is already there
1620
if (!content.startsWith('#!')) {
17-
console.log(`Adding shebang to ${file}`);
21+
console.log(`Adding node shebang to ${file}`);
1822
// Write the file with shebang prepended
19-
fs.writeFileSync(filePath, shebang + content);
23+
fs.writeFileSync(filePath, nodeShebang + content);
2024
// Make the file executable
2125
fs.chmodSync(filePath, '755');
2226
} else {
@@ -25,4 +29,24 @@ files.forEach(file => {
2529
} else {
2630
console.error(`File not found: ${filePath}`);
2731
}
28-
});
32+
});
33+
34+
// Handle browser script
35+
const browserFile = path.join(__dirname, 'browser-global.sh');
36+
if (fs.existsSync(browserFile)) {
37+
// Read the file content
38+
const content = fs.readFileSync(browserFile, 'utf8');
39+
40+
// Check if shebang is already there and set executable flag regardless
41+
fs.chmodSync(browserFile, '755');
42+
43+
if (!content.startsWith('#!')) {
44+
console.log(`Adding sh shebang to browser-global.sh`);
45+
// Write the file with shebang prepended
46+
fs.writeFileSync(browserFile, shFiles + content);
47+
} else {
48+
console.log(`Shebang already exists in browser-global.sh`);
49+
}
50+
} else {
51+
console.error(`File not found: ${browserFile}`);
52+
}

0 commit comments

Comments
 (0)