Good day. It is necessary to make a decision to run the second command based on the results of the previous one.
I need to check if npm package is installed and if it doesn't exist start installing. npm list -g package
(if the package does not exist, this command will return a value different from 0) and npm install -g package
commands are used for the issue. It is easy to execute the logic in a terminal using ||
operator:
npm list -g package || npm install -g package
Then I created installPackage
task in gradle.build file:
task installPackage(type: Exec) {
commandLine 'npm', 'list', '-g', 'package', '||', 'npm', 'install', '-g', 'package'
}
And none of the commands work. In fact, the result is displayed as if npm list -g
command was used.
Is there a way to do this without using third-party tools or plugins? What options could be used? Thanks a lot