def commandLineOf(command, terminal = null) {
if (System.properties['os.name'].toLowerCase().contains('windows')) {
return ['cmd', '/c', command]
} else if (terminal != null) {
return ['bash', '-c', terminal]
} else {
return ['bash', '-c', command]
}
}
task example {
doLast {
exec {
workingDir '.'
commandLine commandLineOf("git fetch")
}
exec {
workingDir '.'
commandLine commandLineOf("dir", "ls")
}
}
}
Last active
November 20, 2020 15:03
-
-
Save joutvhu/21be89cda154cce8c33936aa1866ce65 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment