moon
moon copied to clipboard
[bug/feature] should be able to execute any shell commands
i would like to be able to use execute any shell command in a selectable shell. most users have several cli utilities install that are only available in a certain shell with a profile)
shell: powershell os: win 11 moon: 0.8.0
.moon/project.yml
tasks:
clean:
command: 'rimraf'
type: 'system'
args:
- ' dist'
current error message
$ moon run types:clean
▪▪▪▪ types:clean
ERROR Process failure for rimraf: program not found
rimraf is installed globally with npm
also why cant the command value be a 'sentence' (string with whitespaces), to write the full command of something? if you need any further information please let me know.
@alexn-s This is an interesting one. When type is "system", nothing special happens, the command is simply executed as a child process. I'm assuming the npm global install location isn't within $PATH, so the environment can't find it.
I'm also not sure this is something we should support, as it assumes that all developers and machines (CI) also have rimraf installed globally, otherwise it would break. As an alternative you can do:
tasks:
clean:
command: 'rm'
type: 'system'
args: '-rf dist'
also why cant the command value be a 'sentence' (string with whitespaces), to write the full command of something?
This is being discussed currently but has issues with task merging: https://moonrepo.dev/docs/concepts/task#merge-strategies
hmm ok. npm is in my global paths (environment variables)
and regarding rm, it is only available on unix and not on win without cygwin. also rimraf was just an example.
what i mean/ looking for is to execute any command start . (start windows explorer) start dist/index.html (start web page in default browser), basically i run many cli commands in powershell/ cmd.exe and was trying to create moon scripts with them
@alexn-s Good to know. Any reason why it's simply not a dep in package.json?
yeah, rimraf was just an example. it is not even directly about npm modules, but the ability to exec any shell command that also works in the users default shell
an prime example would be npm scripts:
package.json
"scripts": {
"demo":"start .",
...
}
when running pnpm run start or with npm the command executes fine (start . -> opens the file explorer on windows in current dir).
so in the end i am looking for compatibility between package.json scripts and moon tasks
Long time coming, but system tasks now run in a shell in v1.
wow amazing. thank you. really excited to try moon (finally for me). looks awesome from what i read in your blog and changes. looking forward to test it tomorrow and perhaps replace nx (nrwl). congrats on the first major release
Awesome, let me know if there are any issues or if you have other asks!