Skip to content

Instantly share code, notes, and snippets.

@illume
Last active July 14, 2025 18:25
Show Gist options
  • Select an option

  • Save illume/7cc324c3a6debbce65ee79ebb474a24f to your computer and use it in GitHub Desktop.

Select an option

Save illume/7cc324c3a6debbce65ee79ebb474a24f to your computer and use it in GitHub Desktop.
run script electron
// 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