1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- const _ = require('lodash');
- const shellUtils = require('shell-utils');
- const fs = require('fs');
-
- const release = _.includes(process.argv, 'release');
-
- function hackReactXcodeScript() {
- const fileToHack = `./node_modules/react-native/packager/react-native-xcode.sh`;
- const lines = _.split(String(fs.readFileSync(fileToHack)), '\n');
- lines[11] = release ? '' : `exit 0;`;
- fs.writeFileSync(fileToHack, _.join(lines, '\n'));
- }
-
- function buildProjForDetox() {
- const scheme = release ? `playground_release_Detox` : `playground_Detox`;
-
- shellUtils.exec.execSync(`./scripts/detoxDebugFix.rb ${release ? '' : 'debug'}`);
-
- shellUtils.exec.execSync(`echo -en 'travis_fold:start:xcodebuild\n'`);
-
- const cmd = `RCT_NO_LAUNCH_PACKAGER=true
- cd ios && xcodebuild
- -scheme ${scheme} build
- -project playground.xcodeproj
- -sdk iphonesimulator
- -derivedDataPath ./DerivedData/playground`;
-
- if (hasXcpretty()) {
- shellUtils.exec.execSync(`${cmd} | xcpretty`);
- } else {
- shellUtils.exec.execSync(`${cmd}`);
- }
-
- console.log(`*********** 1`);
-
- shellUtils.exec.execSync(`echo -en 'travis_fold:end:xcodebuild\n'`);
-
- console.log(`*********** 2`);
- }
- function hasXcpretty() {
- try {
- return shellUtils.exec.execSyncRead(`which xcpretty`);
- } catch (e) {
- return false;
- }
- }
-
- function e2e() {
- try {
- console.log(`*********** 3`);
- //shellUtils.exec.execSyncSilent(`watchman watch-del-all || true`);
- //shellUtils.exec.kill(`detox-server`);
- shellUtils.exec.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
- console.log(`*********** 4`);
- //const detoxAppBuildPath = `ios/DerivedData/playground/Build/Products/${release ? 'Release' : 'Debug'}_Detox-iphonesimulator/playground.app`;
- //
- //shellUtils.exec.execSync(`detoxAppBuildPath="${detoxAppBuildPath}"
- // BABEL_ENV=test
- // ./node_modules/mocha/bin/mocha e2e
- // --timeout 120000
- // --recursive
- // --compilers js:babel-register`);
- } finally {
- //shellUtils.exec.execSync(`./scripts/detoxDebugFix.rb`);
- //shellUtils.exec.kill(`detox-server`);
- //if (release) {
- // shellUtils.exec.kill(`Simulator`);
- // shellUtils.exec.kill(`CoreSimulator`);
- //}
- //shellUtils.exec.execSync(`cat ./detox-server.log`);
- //shellUtils.exec.execSync(`rm -f ./detox-server.log`);
- //shellUtils.exec.execSync(`sleep 5`);
- }
- }
-
- function run() {
- hackReactXcodeScript();
- buildProjForDetox();
- e2e();
- }
-
- run();
|