describe('gae_flex_postgres_connect', () => { it('should be listening', async () => { const child = childProcess.exec(`node ${appPath}`); const isOpen = await waitPort({port: PORT}); expect(isOpen).to.be.true; process.kill(child.pid, 'SIGTERM'); }); });
/** * Initializes git again */ function initGit(callback) { exec('git init && git add . && git commit -m "Initial commit"', callback); }
const cmder = async cmd => { return new Promise((resolve, reject) => { exec(cmd, (err, stdout, stderr) => { if(err) { reject(err); return; } resolve('success'); }) }) }
exec( command, { cwd: cwd }, (err, stdout, stderr) => { if(err) console.log(err); global.mainWindow.webContents.send('craOut', stdout) fs.writeFileSync(path.resolve(dest, '.env'), 'SKIP_PREFLIGHT_CHECK=true\nBROWSER=none', { encoding: 'utf8' }, (err) => { if(err) console.log(err); }); global.mainWindow.webContents.send('openDir', dest); } )
exec(command, (error, stdout) => { if (error) { if (error.signal == 'SIGTERM') { resolve('Process was killed'); } else { reject(error); } } else { resolve(stdout.trim()); } });
describe('lookupEntry lookup', () => { it('should lookup a dataset entry', (done) => { const projectId = 'bigquery-public-data'; const datasetId = 'new_york_taxi_trips'; const expectedLinkedResource = `//bigquery.googleapis.com/projects/${projectId}/datasets/${datasetId}`; exec( `node lookupEntry.js ${projectId} ${datasetId}`, {cwd}, (err, stdout) => { assert.ok(stdout.includes(expectedLinkedResource)); done(); } ); }); });
exec('node -v', function (err, stdout) { if (err) throw err; if (parseFloat(stdout.slice(1)) < 8) { throw new Error('React Slingshot requires node 8.0 or greater.'); } });
exec(command, { maxBuffer: 1024 * 1024 }, (error, stdout) => { if (error) { // Special case for robocopy, which will return non-zero error codes // when sucessful. Doc is very imprecise but <= 7 seems more or less // fine and >= 8 seems more errorish. https://ss64.com/nt/robocopy-exit.html if (command.indexOf('robocopy') === 0 && error.code <= 7) { resolve(stdout.trim()); return; } if (error.signal == 'SIGTERM') { resolve('Process was killed'); } else { const newError = new Error(`Code: ${error.code}: ${error.message}: ${stdout.trim()}`); reject(newError); } } else { resolve(stdout.trim()); } });
// 20 MB /** * @description Execute a command and return results. * @param {string} command - The command to execute. * @returns {Promise} Resolve if command resolve. * @example * exec('ls'); */ function exec(command) { return new Promise((resolve, reject) => { childProcess.exec(command, { maxBuffer: MAX_BUFFER_SIZE }, (err, stdout, stderr) => { if (err) { logger.debug(`Exec: Fail to execute command ${command}`); logger.debug(err); logger.debug(stderr); return reject(err); } return resolve(stdout); }); }); }
/** * Installs dependencies */ function installDeps() { exec('node --version', (err, stdout) => { const nodeVersion = stdout && parseFloat(stdout.substring(1)); if (nodeVersion < 7 || err) { installDepsCallback( err || 'Unsupported node.js version, make sure you have the latest version installed.' ); } else { installDepsCallback(); } }); }
const closeSim = (pid) => { //Killall Node let command = `kill -9 ${pid}` let child = exec( command, (err, stdout, stderr) => { if(err) console.log(err); global.mainWindow.webContents.send('closeSim', 'helloworld'); } ); }
describe('server listening', () => { it('should be listening', async () => { await childProcess.exec(`node ${appPath}`); const isOpen = await waitPort({port: PORT}); expect(isOpen).to.be.true; }); });
function pwm (pin, value) { return exec(`echo "${pin}=${parseFloat(value)}" > /dev/pi-blaster`); }
describe('server listening', () => { it('should be listening', async () => { const child = childProcess.exec(`node ${appPath}`); const isOpen = await waitPort({port: PORT}); expect(isOpen).to.be.true; process.kill(child.pid, 'SIGTERM'); }); });