如何在 package.json 脚本中 运行 多个命令?
How can I run multiple commands in package.json scripts?
我正在使用 detox
对我的 react-native 应用程序进行端到端测试。当我尝试 运行 yarn detox build -c android.emu.release
它不 运行 脚本很好 cd android ; ./gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -
。此脚本由 detox init
.
自动生成
这是我的 package.json
文件:
{
"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"
}
}
/*...*/
},
/*...*/
}
例如,我正在努力 运行 yarn detox build -c android.emu.release
。如果
在排毒时我需要使用哪个 symbol/char 来连接命令而不是 ;
?
我认为的主要错误是:The system cannot find the path specified.
从下面提取。
$ 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.
您应该在任何平台上使用 &&
到 运行 多个命令,以及 npm 脚本中的任何 shell。你会认为它在电源上不起作用shell但实际上它确实如此。
[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
我正在使用 detox
对我的 react-native 应用程序进行端到端测试。当我尝试 运行 yarn detox build -c android.emu.release
它不 运行 脚本很好 cd android ; ./gradlew assembleRelease app:assembleAndroidTest -DtestBuildType=release ; cd -
。此脚本由 detox init
.
这是我的 package.json
文件:
{
"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"
}
}
/*...*/
},
/*...*/
}
例如,我正在努力 运行 yarn detox build -c android.emu.release
。如果
在排毒时我需要使用哪个 symbol/char 来连接命令而不是 ;
?
我认为的主要错误是:The system cannot find the path specified.
从下面提取。
$ 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.
您应该在任何平台上使用 &&
到 运行 多个命令,以及 npm 脚本中的任何 shell。你会认为它在电源上不起作用shell但实际上它确实如此。
[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