📢📢📢📢📢 You should use execa instead. 📢📢📢📢
Run script easy!
npm install runscript
Commonjs
const { runScript } = require('runscript');
runScript('node -v', { stdio: 'pipe' })
.then(stdio => {
console.log(stdio);
})
.catch(err => {
console.error(err);
});
ESM & TypeScript
import { runScript } from 'runscript';
runScript('node -v', { stdio: 'pipe' })
.then(stdio => {
console.log(stdio);
})
.catch(err => {
console.error(err);
});
Run user script for a maximum of 10 seconds.
const { runScript } = require('runscript');
runScript('node user-script.js', { stdio: 'pipe' }, { timeout: 10000 })
.then(stdio => {
console.log(stdio);
})
.catch(err => {
console.error(err);
});
// 1.x
// const runscript = require('runscript');
// 2.x
const { runscript } = require('runscript');
Made with contributors-img.