-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for Windows NPM #658
base: main
Are you sure you want to change the base?
Changes from 2 commits
6148029
8fb15a2
18d5cca
496d1b3
d9b3c4a
53f14df
bea2d07
14001b5
2ddeb9f
e9a4f24
bdafb28
b7316d2
8f7d68d
9b531fb
09a6a51
9115d5e
061af90
b18bfb5
f0a3771
ed900ae
6d8c376
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 |
---|---|---|
|
@@ -3,10 +3,14 @@ module Wasp.Generator.Common | |
nodeVersionRange, | ||
npmVersionRange, | ||
prismaVersion, | ||
oSSpecificNpm, | ||
compileOsSpecificNodeCommand | ||
) | ||
where | ||
|
||
import qualified Wasp.SemanticVersion as SV | ||
import System.Info (os) | ||
import Data.List | ||
|
||
-- | Directory where the whole web app project (client, server, ...) is generated. | ||
data ProjectRootDir | ||
|
@@ -38,3 +42,12 @@ npmVersionRange = | |
|
||
prismaVersion :: SV.Version | ||
prismaVersion = SV.Version 3 15 2 | ||
|
||
oSSpecificNpm :: [Char] | ||
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. Nice job, you put this in the best place in the codebase I think :), finding your way around well I see! Maybe we can just call this function A bit of Haskell: instead of 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. Maybe we could also provide a short comment explaining why is it important to add this .cmd on windows, since it took us some time to figure that out, and if somebody later stumbles onto this, they might wonder why we are adding this 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. @Martinsos for Strings--got it, did not think haskell has those) For exmplanation comment--no problem. Should I leave a text explanation or leave a link to SO? 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. Maybe best to do both: text explanation + SO link! Your explanations here in description are already very good, smth very similar should do just fine. |
||
oSSpecificNpm = "npm" ++ if os /= "mingw32" then "" else ".cmd" | ||
|
||
compileOsSpecificNodeCommand :: [Char] -> [[Char]] -> ([Char], [[Char]]) | ||
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. We could maybe also call this one just s/[Char]/String Here we could also benefit from a comment explaining the reasoning behind the stuff we have to do for Windows. In this case it would also explain it to me since right now I don't understand why we have to do this :D! I thought EDIT: reading code below, I realized this command here and args are not But most important will be documenting what is the intention of this function, then further direction will be clearer. |
||
compileOsSpecificNodeCommand command arguments = | ||
if os /= "mingw32" | ||
then (command, arguments) | ||
else ("cmd.exe", [intercalate " " (["/c", command] ++ arguments)]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ runNodeCommandAsJob fromDir command args jobType chan = do | |
Right nodeVersion -> | ||
if SV.isVersionInRange nodeVersion C.nodeVersionRange | ||
then do | ||
let process = (P.proc command args) {P.cwd = Just $ SP.fromAbsDir fromDir} | ||
let (specificCommand, specificArgs) = C.compileOsSpecificNodeCommand 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. Looking at So, it should probably be renamed to 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. As for using If so, should we use it for all commands we are trying to run, and not just here? What about us calling node directly, I see that below we are calling 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. Ok, so now I read what you wrote about The question is then: Do we want to use this trick only when calling In that case, let's use it like that, only for buildNpmCmdWithArgs :: [String] -> (String, [String]) and that is it? And then we call it only in places where we need to call |
||
let process = (P.proc specificCommand specificArgs) {P.cwd = Just $ SP.fromAbsDir fromDir} | ||
runProcessAsJob process jobType chan | ||
else | ||
exitWithError | ||
|
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.
We try to import stuff qualified or named, so we don't pollute the namespace.
Therefore, best to do
import Data.List (intercalate)
!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.
Done