-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix #48: Missing npm on native Windows #3020
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ runNodeCommandAsJobWithExtraEnv extraEnvVars fromDir command args jobType chan = | |
NodeVersion.VersionCheckFail errorMsg -> exitWithError (ExitFailure 1) (T.pack errorMsg) | ||
NodeVersion.VersionCheckSuccess -> do | ||
envVars <- getAllEnvVars | ||
let nodeCommandProcess = (P.proc command args) {P.env = Just envVars, P.cwd = Just $ SP.fromAbsDir fromDir} | ||
let nodeCommandProcess = (P.shell fullCommand) {P.env = Just envVars, P.cwd = Just $ SP.fromAbsDir fromDir} | ||
runProcessAsJob nodeCommandProcess jobType chan | ||
where | ||
-- Haskell will use the first value for variable name it finds. Since env | ||
|
@@ -119,3 +119,4 @@ runNodeCommandAsJobWithExtraEnv extraEnvVars fromDir command args jobType chan = | |
J._jobType = jobType | ||
} | ||
return exitCode | ||
fullCommand = unwords $ command : args | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is one thing I am not sure about: are we missing out on any args escaping here? So before we were giving command and args to P.proc, and I guess it was potentially doing some manipulation with those args. Now it is just one big string (command + args) -> could that be an issue? Should we be wrapping args into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @Martinsos, Thanks for reviewing. I've checked the source code of both P.proc and P.shell. Indeed, P.proc is the modern and safe version of P.shell (see https://github.com/haskell/process/blame/98101f82543b3a28e9f5192d758a508881f8b464/System/Process/Windows.hsc#L423). I think that we are going to reinvent the wheel by trying to escape args for P.shell. After reviewing these things, I've changed my mind to go for P.proc. (cont. below) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ where | |
|
||
import Data.Conduit.Process.Typed (ExitCode (..)) | ||
import System.IO.Error (catchIOError, isDoesNotExistError) | ||
import System.Process (readProcessWithExitCode) | ||
import System.Process (readCreateProcessWithExitCode, shell) | ||
import Wasp.Node.Internal (parseVersionFromCommandOutput) | ||
import qualified Wasp.SemanticVersion as SV | ||
import qualified Wasp.SemanticVersion.VersionBound as SV | ||
|
@@ -76,7 +76,7 @@ readCommandOutput :: String -> [String] -> IO (Either ErrorMessage String) | |
readCommandOutput commandName commandArgs = do | ||
commandResult <- | ||
catchIOError | ||
(Right <$> readProcessWithExitCode commandName commandArgs "") | ||
(Right <$> readCreateProcessWithExitCode (shell fullCommand) "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm same question here as above, do we need to somehow do something with arguments? fullCommand was used only for printing so that was fine, but now we are passing it to shell. |
||
(return . Left . wrapCommandIOErrorMessage . makeIOErrorMessage) | ||
return $ case commandResult of | ||
Left procErr -> Left procErr | ||
|
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.
I would add some comment here, explaining why it is important that we use
shell
and notproc
, so future readers don't wonder whyshell
was used.