const _ = require('lodash');
const exec = require('shell-utils').exec;

const android = _.includes(process.argv, '--android');
const release = _.includes(process.argv, '--release');
const skipBuild = _.includes(process.argv, '--skipBuild');

run();

function run() {
  const platform = android ? `android` : `ios`;
  const prefix = android ? `android.emu` : `ios.sim`;
  const suffix = release ? `release` : `debug`;
  const configuration = `${prefix}.${suffix}`;
  const cleanup = process.env.JENKINS_CI ? `--cleanup` : ``;

  if (!skipBuild) {
    exec.execSync(`detox build --configuration ${configuration}`);
  }
  exec.execSync(`detox test --configuration ${configuration} --platform ${platform} ${cleanup}`);
}

@@ -233,16 +233,73 @@
 Build');
+%0Aconst headless = _.includes(process.argv, '--headless');
 %0A%0Arun();
@@ -319,16 +319,18 @@
 n() %7B%0A  
+ 
+ 
 const pl
@@ -367,16 +367,18 @@
  %60ios%60;%0A
+  
   const 
@@ -423,16 +423,18 @@
 s.sim%60;%0A
+  
   const 
@@ -473,16 +473,18 @@
 debug%60;%0A
+  
   const 
@@ -522,16 +522,18 @@
 ffix%7D%60;%0A
+  
   const 
@@ -558,16 +558,8 @@
 env.
-JENKINS_
 CI ?
@@ -577,17 +577,86 @@
 %60 : %60%60;%0A
-%0A
+    const headless$ = android ? headless ? %60--headless%60 : %60%60 : %60%60;%0A%0A  
   if (!s
@@ -671,16 +671,20 @@
 ) %7B%0A    
+ 
+   
 exec.exe
@@ -740,18 +740,22 @@
 n%7D%60);%0A  
-%7D%0A
+  %7D%0A  
   exec.e
@@ -840,14 +840,27 @@
 cleanup%7D
+ $%7Bheadless$%7D
 %60);%0A%7D%0A

Add headless option to e2e android