Skip to content

Instantly share code, notes, and snippets.

@Pierstoval
Created February 11, 2022 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pierstoval/7d65014c039699c69cb2f9c5c96fd342 to your computer and use it in GitHub Desktop.
Save Pierstoval/7d65014c039699c69cb2f9c5c96fd342 to your computer and use it in GitHub Desktop.
A Node.js script to run both Node frontend & Rust backend when developing with Tauri
import {spawn} from "child_process";
const yarn_path = process.env.npm_execpath;
const node_path = process.env.npm_node_execpath;
const create_process = function(name, args) {
let child = spawn(node_path, [yarn_path, ...args], {stdio: 'inherit'});
child.on('close', (code) => console.log(`child process ${name} exited with code ${code}`));
return child;
}
create_process('FRONTEND', ['run', 'dev']);
create_process('BACKEND', ['run', 'tauri', 'dev']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment