-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace call to shellwords with a call to system passing an array #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that this pattern doesn't work on Windows! This PR's code is simpler and easier to read.
I have a slight preference for exec
rather than system
(they both work with a splat of arguments) to avoid an additional process being created, but that's not a terribly good reason and in a development environment it's unlikely to make much difference either way.
If it becomes important later, we can use os.windows? and use I'm still puzzled why I couldn't get |
Note that this is a pretty heavy refactoring, where code was moved from `exe/tailwindcss` to `lib/tailwindcss/commands.rb` where we can more easily run unit tests on it. Note also that we no longer use Shellwords to build command strings, a library which does not generate correct strings on Windows platforms. Instead we consistently use arrays of command arguments, which can be passed to `exec` or `system` however we see fit. The wrapper script conditionally uses `system` on windows platforms because `exec` can't find the executable (see related issue at rubys/sprockets-esbuild#4). Finally, note that the rake tasks no longer use the `exe/tailwindcss` wrapper script, and instead use the binary executable directly. We can reverse this decision if we ever decide to support manually-installed tailwindcss somewhere on the $PATH; but because previously the rake tasks hardcoded the path/to/exe/tailwindcss, we're not introducing any new constraints by skipping the wrapper.
Note that this is a pretty heavy refactoring, where code was moved from `exe/tailwindcss` to `lib/tailwindcss/commands.rb` where we can more easily run unit tests on it. Note also that we no longer use Shellwords to build command strings, a library which does not generate correct strings on Windows platforms. Instead we consistently use arrays of command arguments, which can be passed to `exec` or `system` however we see fit. The wrapper script conditionally uses `system` on windows platforms because `exec` can't find the executable (see related issue at rubys/sprockets-esbuild#4). Finally, note that the rake tasks no longer use the `exe/tailwindcss` wrapper script, and instead use the binary executable directly. We can reverse this decision if we ever decide to support manually-installed tailwindcss somewhere on the $PATH; but because previously the rake tasks hardcoded the path/to/exe/tailwindcss, we're not introducing any new constraints by skipping the wrapper.
Note that this is a pretty heavy refactoring, where code was moved from `exe/tailwindcss` to `lib/tailwindcss/commands.rb` where we can more easily run unit tests on it. Note also that we no longer use Shellwords to build command strings, a library which does not generate correct strings on Windows platforms. Instead we consistently use arrays of command arguments, which can be passed to `exec` or `system` however we see fit. The wrapper script conditionally uses `system` on windows platforms because `exec` can't find the executable (see related issue at rubys/sprockets-esbuild#4). Finally, note that the rake tasks no longer use the `exe/tailwindcss` wrapper script, and instead use the binary executable directly. We can reverse this decision if we ever decide to support manually-installed tailwindcss somewhere on the $PATH; but because previously the rake tasks hardcoded the path/to/exe/tailwindcss, we're not introducing any new constraints by skipping the wrapper.
Note that this is a pretty heavy refactoring, where code was moved from `exe/tailwindcss` to `lib/tailwindcss/commands.rb` where we can more easily run unit tests on it. Note also that we no longer use Shellwords to build command strings, a library which does not generate correct strings on Windows platforms. Instead we consistently use arrays of command arguments, which can be passed to `exec` or `system` however we see fit. The wrapper script conditionally uses `system` on windows platforms because `exec` can't find the executable (see related issue at rubys/sprockets-esbuild#4). Finally, note that the rake tasks no longer use the `exe/tailwindcss` wrapper script, and instead use the binary executable directly. We can reverse this decision if we ever decide to support manually-installed tailwindcss somewhere on the $PATH; but because previously the rake tasks hardcoded the path/to/exe/tailwindcss, we're not introducing any new constraints by skipping the wrapper.
Note that this is a pretty heavy refactoring, where code was moved from `exe/tailwindcss` to `lib/tailwindcss/commands.rb` where we can more easily run unit tests on it. Note also that we no longer use Shellwords to build command strings, a library which does not generate correct strings on Windows platforms. Instead we consistently use arrays of command arguments, which can be passed to `exec` or `system` however we see fit. The wrapper script conditionally uses `system` on windows platforms because `exec` can't find the executable (see related issue at rubys/sprockets-esbuild#4). Finally, note that the rake tasks no longer use the `exe/tailwindcss` wrapper script, and instead use the binary executable directly. We can reverse this decision if we ever decide to support manually-installed tailwindcss somewhere on the $PATH; but because previously the rake tasks hardcoded the path/to/exe/tailwindcss, we're not introducing any new constraints by skipping the wrapper.
Shellwords is not compatible with Windows.
While
--help
works, other common esbuild options do not, for example:The most obvious fix, namely calling exec with an array of arguments curiously fails on windows with an error of the executable not being found.
Surprisingly, the exact same invocation using
system
instead ofexec
works.