Skip to content

Commit

Permalink
Fix exec and spawn from child_process
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek committed Sep 2, 2022
1 parent b020b13 commit 66052a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 16 additions & 8 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs');
const http = require('http');
const spawn = require('child_process').spawn;
const child_process = require('child_process');
const argv = require('yargs').argv;
const path = require('path');

Expand Down Expand Up @@ -62,7 +62,6 @@ try {
exitCode = 1;
throw Error(exitCode);
}
echo('set-rn-version script was run');

if (exec('npm pack').code) {
echo('Failed to pack react-native');
Expand All @@ -73,7 +72,10 @@ try {
const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz');

describe('Verdaccio');
exec('npx verdaccio --config ../.circleci/verdaccio/config.yaml &');
// TODO: Kill verdaccio
child_process.spawn(
'npx verdaccio --config ../.circleci/verdaccio/config.yaml',
);
exec('npm set registry http://localhost:4873');

function queryForServerStatus() {
Expand Down Expand Up @@ -190,7 +192,9 @@ try {
}

describe(`Start appium server, ${APPIUM_PID}`);
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
const appiumProcess = child_process.spawn('node', [
'./node_modules/.bin/appium',
]);
APPIUM_PID = appiumProcess.pid;

describe('Build the app');
Expand All @@ -202,9 +206,13 @@ try {

describe(`Start Metro, ${SERVER_PID}`);
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], {
env: process.env,
});
const packagerProcess = child_process.spawn(
'yarn',
['start', '--max-workers 1'],
{
env: process.env,
},
);
SERVER_PID = packagerProcess.pid;
// wait a bit to allow packager to startup
exec('sleep 15s');
Expand All @@ -231,7 +239,7 @@ try {
const packagerEnv = Object.create(process.env);
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
describe('Start Metro');
const packagerProcess = spawn('yarn', ['start'], {
const packagerProcess = child_process.spawn('yarn', ['start'], {
stdio: 'inherit',
env: packagerEnv,
});
Expand Down
1 change: 0 additions & 1 deletion scripts/set-rn-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ let major,
try {
({major, minor, patch, prerelease} = parseVersion(version));
} catch (e) {
echo('I did exit');
echo(e.message);
exit(1);
}
Expand Down

0 comments on commit 66052a4

Please sign in to comment.