{"size": 411, "ext": "js", "max_stars_repo_path": "routes/scripts/run/:script.js", "max_stars_repo_name": "azz/dev-ui", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/scripts/run/:script.js", "max_issues_repo_name": "azz/dev-ui", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routes/scripts/run/:script.js", "max_forks_repo_name": "azz/dev-ui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6875, "max_line_length": 59, "alphanum_fraction": 0.5839416058}
const {send} = require('micro');
const hasYarn = require('has-yarn');
const execa = require('execa');

module.exports = async ({params: {script}, on}, res) => {
  try {
    const command = hasYarn() ? 'yarn' : 'npm';
    const {stdout, kill} = execa(command, ['run', script]);
    stdout.pipe(process.stdout);
    send(res, 200, stdout);
    on('close', kill);
  } catch (err) {
    send(res, 404, err);
  }
};
