Last active
July 14, 2025 18:25
-
-
Save illume/7cc324c3a6debbce65ee79ebb474a24f to your computer and use it in GitHub Desktop.
run script electron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Run a node script with electron. | |
| const scriptPath = path.join(__dirname, '..', 'my-script.js'); | |
| console.log(scriptPath) | |
| spawn(process.execPath, [scriptPath], { | |
| stdio: 'inherit', | |
| }); | |
| import { pathToFileURL } from 'url'; | |
| import process from 'process'; | |
| const scriptPath = process.argv[2]; | |
| const scriptArgs = process.argv.slice(3); | |
| process.argv = [process.execPath, scriptPath, ...scriptArgs]; | |
| await import(pathToFileURL(scriptPath).href); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment