Skip to content

Commit

Permalink
troubleshooting npx distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
toddtarsi committed Dec 25, 2023
1 parent cf2205a commit 10c338b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
39 changes: 31 additions & 8 deletions packages/selenium-ide/bin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
#!/usr/bin/env node
const { join } = require('path');
const { spawn } = require('child_process');
const electronPath = require('electron');
const { join } = require('path')
const { spawn } = require('child_process')

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

const electronProcess = spawn(electronPath, [appPath]);
electronProcess.stdout.on('data', (data) => process.stdout.write(data));
electronProcess.stderr.on('data', (data) => process.stderr.write(data));
electronProcess.on('close', (code) => process.exit(code));
async function installElectron() {
// Read package.json
const packageJson = JSON.parse(fs.readFile('package.json', 'utf8'))
// Get the Electron version from package.json
const electronVersion = packageJson.devDependencies.electron
// Install Electron
console.log(`Installing Electron ${electronVersion}...`)
execSync(`npm i electron@${electronVersion}`, { stdio: 'inherit' })
console.log('Electron installed successfully.')
}

const main = async () => {
let electronPath
try {
electronPath = require('electron')
} catch (e) {
await installElectron()
}
electronPath = require('electron')
const appPath = join(__dirname, 'build', 'main-bundle.js')
const electronProcess = spawn(electronPath, [appPath])
electronProcess.stdout.on('data', (data) => process.stdout.write(data))
electronProcess.stderr.on('data', (data) => process.stderr.write(data))
electronProcess.on('close', (code) => process.exit(code))
}

main()
2 changes: 1 addition & 1 deletion packages/selenium-ide/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selenium-ide",
"version": "4.0.1-alpha.65",
"version": "4.0.1-alpha.66",
"private": false,
"description": "Selenium IDE electron app",
"author": "Todd <[email protected]>",
Expand Down

0 comments on commit 10c338b

Please sign in to comment.