Skip to content

Commit 2480c0f

Browse files
committed
feat: add workflow for code formatting and fix npx command download issue
1 parent 2993c43 commit 2480c0f

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,32 @@ on:
66
pull_request:
77
branches: [main]
88

9-
env:
10-
NODE_VERSION: 16.x
11-
129
jobs:
13-
typecheck:
10+
build:
1411
runs-on: ubuntu-latest
1512

1613
steps:
17-
- uses: actions/setup-node@v3
18-
with:
19-
node-version: ${{ env.NODE_VERSION }}
20-
- uses: actions/checkout@v3
21-
- run: |
22-
npm install
23-
npm run typecheck
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.head_ref }}
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run type check
28+
run: npm run typecheck
29+
30+
- name: Format code
31+
run: npm run format
32+
33+
- name: Commit changes
34+
uses: stefanzweifel/git-auto-commit-action@v5
35+
with:
36+
commit_message: "style: format code with prettier"
37+
branch: ${{ github.head_ref }}

cpp/whisper.cpp

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"access": "public"
99
},
1010
"bin": {
11-
"download": "dist/downloadModel.js"
11+
"nodejs-whisper": "dist/downloadModel.js"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -43,13 +43,7 @@
4343
"nodejs-whisper",
4444
"audio-to-subtitles"
4545
],
46-
"author": "chetan baliyan",
47-
"contributors": [
48-
{
49-
"name": "Michael Heuberger",
50-
"email": "[email protected]"
51-
}
52-
],
46+
"author": "chetan",
5347
"license": "MIT",
5448
"homepage": "https://github.com/ChetanXpro/nodejs-whisper#readme",
5549
"bugs": {

src/downloadModel.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const askIfUserWantToUseCuda = async (logger = console) => {
4646
}
4747
}
4848

49-
export default async function downloadModel(logger = console) {
49+
async function downloadModel(logger = console) {
5050
try {
5151
shell.cd(path.join(__dirname, '..', './cpp/whisper.cpp/models'))
5252

@@ -60,11 +60,10 @@ export default async function downloadModel(logger = console) {
6060
})
6161

6262
if (anyModelExist.length > 0) {
63-
return
64-
// logger.log('Models already exist. Skipping download.')
65-
} else {
66-
logger.log('[Nodejs-whisper] Models do not exist. Please Select a model to download.\n')
67-
}
63+
console.log('\n[Nodejs-whisper] Currently installed models:')
64+
anyModelExist.forEach(model => console.log(`- ${model}`))
65+
console.log('\n[Nodejs-whisper] You can install additional models from the list below.\n')
66+
}
6867

6968
logger.log(`
7069
| Model | Disk | RAM |
@@ -115,4 +114,8 @@ export default async function downloadModel(logger = console) {
115114
}
116115
}
117116
// run on npx nodejs-whisper download
118-
downloadModel()
117+
downloadModel().catch(error => {
118+
console.error('Failed to download:', error)
119+
process.exit(1)
120+
})
121+

0 commit comments

Comments
 (0)