0

I'm using detox for end-to-end testing my react-native app. When I try to run yarn detox build -c android.emu.release it does not run the script well cd android ; ./gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -. This script was generated automatically by detox init.

Here is my package.json file:

{
  "detox": {
    /*...*/
    "android.emu.release": {
        "binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
        "build": "cd android  ./gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -", //<<<<<<<<<<<
        "type": "android.emulator",
        "device": {
          "avdName": "NexusOneAPI29"
        }
      }
    /*...*/
  },
  /*...*/
}

I am struggling to run yarn detox build -c android.emu.release for instance. If

Which symbol/char do I need to use to concat commands instead of ; on detox?

The main error I believe is: The system cannot find the path specified. extracted from below.

$ yarn detox-build                                                  
yarn run v1.21.1
detox[7600] INFO:  [build.js] cd android ; gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -
The system cannot find the path specified.
detox[7600] ERROR: [cli.js] Error: Command failed: cd android ; gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=releas
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
8
  • are you trying to have shell script inside ? Commented Jan 23, 2020 at 21:25
  • 1
    stackoverflow.com/questions/34937724/… Commented Jan 23, 2020 at 21:29
  • I know you are targeting Android, but what envrioment are you running the npm scripts from? Have you tried using && instead of ;? Commented Jan 23, 2020 at 21:34
  • I did try && but it does not work on Powershell on Windows :'( Commented Jan 23, 2020 at 21:35
  • 1
    @AlexandreLage - Yes, you're right, I forgot that I created an alias for the which command in Powershell some time ago. You'd need to run get-command cmd.exe instead. However, it's not relevant now as your issue is very different from the original question. Commented Jan 24, 2020 at 14:18

1 Answer 1

2

You should use && to run multiple commands on any platform and any shell from npm scripts. You would expect it does not work on powershell but it does actually.

[npm] doesn't have the exact same semantics for && (it executes the second command regardless of the success of the first), but it does work to string together multiple commands on a line.

https://github.com/npm/npm/issues/4040#issuecomment-209034612

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. You are right. I updated my question as I realized the problem is not using && with npm scripts but with detox script. Voted you up

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.