const run = (type) => { process.stderr.write(`benchmarking ${type}\n`) return execSync(`node ${join(__dirname, 'runbench')} ${type} -q`) }
writeTerminalData(stream, data) { const buffer = Buffer.from(data, 'base64'); if (stream === 'stderr') process.stderr.write(buffer); else if (stream === 'stdout') process.stdout.write(buffer); }
/** * @description Execute a command in a container image. * @param {string} containerId - Container id. * @param {Object} options - Command to execute. * @returns {Promise<Object>} The state of the command. * @example * const state = await exec(containerId, options); */ async function exec(containerId, options) { if (!this.dockerode) { throw new PlatformNotCompatible('SYSTEM_NOT_RUNNING_DOCKER'); } const container = await this.dockerode.getContainer(containerId); const executable = await container.exec(options); return new Promise((resolve, reject) => { executable.start((err, stream) => { if (err) { reject(err); } else { stream.on('end', () => { resolve(true); }); this.dockerode.modem.demuxStream(stream, process.stdout, process.stderr); } }); }); }
/** * Callback function after installing dependencies */ function installDepsCallback(error) { process.stdout.write('\n\n'); if (error) { process.stderr.write(error); process.stdout.write('\n'); process.exit(1); } deleteFileInCurrentDir('setup.js', () => { process.stdout.write('Initialising new repository...'); initGit(() => { cleanSetup(() => { updateReadme(() => { clear(); process.stdout.write('\n'); process.stdout.write('\nRAN! is ready to go!'); process.stdout.write('\n'); process.stdout.write('\n'); process.exit(0); }); }); }); }); }
if (err.code === 'EADDRINUSE') { process.stderr.write(`Unable to listen on port ${err.port}. The port is already in use.`); process.exit(0); } else {
function executeCommands(keys) { keys.forEach(key => { execSync(`${runner} run ${key}${getTrailingOptions()}`, { cwd, stdio: [process.stdin, process.stdout, process.stderr] }); }); }
function release(state, argv) { const logStream = process.stdout.isTTY ? process.stdout : process.stderr; const cli = new CLI(logStream); const dir = process.cwd(); return runPromise(main(state, argv, cli, dir)).catch((err) => { if (cli.spinner.enabled) { cli.spinner.fail(); } throw err; }); }
/** * @description Execute a command in a container image. * @param {string} containerId - Container id. * @param {Object} options - Command to execute. * @returns {Promise<Object>} The state of the command. * @example * const state = await exec(containerId, options); */ async function exec(containerId, options) { if (!this.dockerode) { throw new PlatformNotCompatible('SYSTEM_NOT_RUNNING_DOCKER'); } const container = await this.dockerode.getContainer(containerId); const executable = await container.exec(options); return new Promise((resolve, reject) => { executable.start((err, stream) => { if (err) { reject(err); } else { stream.on('end', () => { resolve(true); }); this.dockerode.modem.demuxStream(stream, process.stdout, process.stderr); } }); }); }