Skip to content

Commit 10c338b

Browse files
committed
troubleshooting npx distribution
1 parent cf2205a commit 10c338b

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

packages/selenium-ide/bin.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
#!/usr/bin/env node
2-
const { join } = require('path');
3-
const { spawn } = require('child_process');
4-
const electronPath = require('electron');
2+
const { join } = require('path')
3+
const { spawn } = require('child_process')
54

6-
const appPath = join(__dirname, 'build', 'main-bundle.js');
5+
const { execSync } = require('child_process')
6+
const fs = require('fs/promises')
77

8-
const electronProcess = spawn(electronPath, [appPath]);
9-
electronProcess.stdout.on('data', (data) => process.stdout.write(data));
10-
electronProcess.stderr.on('data', (data) => process.stderr.write(data));
11-
electronProcess.on('close', (code) => process.exit(code));
8+
async function installElectron() {
9+
// Read package.json
10+
const packageJson = JSON.parse(fs.readFile('package.json', 'utf8'))
11+
// Get the Electron version from package.json
12+
const electronVersion = packageJson.devDependencies.electron
13+
// Install Electron
14+
console.log(`Installing Electron ${electronVersion}...`)
15+
execSync(`npm i electron@${electronVersion}`, { stdio: 'inherit' })
16+
console.log('Electron installed successfully.')
17+
}
18+
19+
const main = async () => {
20+
let electronPath
21+
try {
22+
electronPath = require('electron')
23+
} catch (e) {
24+
await installElectron()
25+
}
26+
electronPath = require('electron')
27+
const appPath = join(__dirname, 'build', 'main-bundle.js')
28+
const electronProcess = spawn(electronPath, [appPath])
29+
electronProcess.stdout.on('data', (data) => process.stdout.write(data))
30+
electronProcess.stderr.on('data', (data) => process.stderr.write(data))
31+
electronProcess.on('close', (code) => process.exit(code))
32+
}
33+
34+
main()

packages/selenium-ide/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-ide",
3-
"version": "4.0.1-alpha.65",
3+
"version": "4.0.1-alpha.66",
44
"private": false,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",

0 commit comments

Comments
 (0)