Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created February 6, 2019 21:39
Show Gist options
  • Save colinfwren/302a0fce6b81cfffb35d4b5613fee3c0 to your computer and use it in GitHub Desktop.
Save colinfwren/302a0fce6b81cfffb35d4b5613fee3c0 to your computer and use it in GitHub Desktop.
Example controller
server.post('/test-runs', async (req, res, next) => {
try{
console.log('Kicking off test run');
exec('npm test', (error, stdout, stderr) => {
if (error) {
console.error(`Error running tests: ${error.message}`);
}
console.log(stdout);
console.error(stderr);
});
res.send(200);
} catch (err) {
res.send(500, { error: err.message });
}
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment