Closed AaronNGray closed 6 years ago
This is expected behavior, so I'll close this (but I'm happy to answer further questions).
Unix and Windows handle glob (wildcard) expansion differently. I think this blog post has a pretty good explanation. TL;DR Unix shells expand globs before launching the command, Windows shells don't (the program must expand globs itself).
If you're running your command on unix, you're seeing unix expansion at play (and shx
can't turn that off). If you're running on Windows, shx
intentionally emulates unix expansion for consistent behavior across the platforms.
In your specific case, I recommend writing a for-loop:
for file in test/*.js; do
shx mv "$file" "test/${file%.js}.mjs"
done
Or, use shelljs to make it cross-platform:
shell.ls('test/*.js').forEach(file => {
shell.mv(file, file.replace(/\.js$/, '.mjs'));
});
The following is not working :-
getting the following error :-