Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-rescript-app",
"version": "1.12.0-beta.2",
"version": "1.12.0-beta.3",
"description": "Quickly create new ReScript apps from project templates.",
"main": "out/create-rescript-app.cjs",
"scripts": {
Expand Down
17 changes: 16 additions & 1 deletion src/PackageManagers.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,23 @@ let defaultPackagerInfo = {packageManager: Npm, command: "npm"}
@scope(("process", "env"))
external npm_execpath: option<string> = "npm_execpath"

@scope(("process", "env"))
external npm_config_user_agent: option<string> = "npm_config_user_agent"

let isPnpmUserAgent = () =>
switch npm_config_user_agent {
| Some(userAgent) =>
userAgent
->String.toLowerCase
->String.split(" ")
->Array.some(segment => segment->String.startsWith("pnpm/"))
| None => false
}

let getPackageManagerInfo = async () =>
// Note: pnpm does not set npm_execpath
switch npm_execpath {
| None if isPnpmUserAgent() => {packageManager: Pnpm, command: "pnpm"}
| None => defaultPackagerInfo
| Some(execPath) =>
// #58: Windows: packageManager may be something like
Expand All @@ -41,7 +56,7 @@ let getPackageManagerInfo = async () =>
let isYarn1 = CompareVersions.compareVersions(version, "2.0.0")->Ordering.isLess

Some(isYarn1 ? Yarn1 : YarnBerry)
| _ if filename->String.includes("pnpm") => Some(Pnpm)
| _ if filename->String.includes("pnpm") => Some(Pnpm) // in case pnpm sets npm_execpath in a future version
| _ if filename->String.includes("npm") => Some(Npm) // make sure this goes after pnpm ...
| _ if filename->String.includes("bun") => Some(Bun)
| _ => None
Expand Down
6 changes: 5 additions & 1 deletion src/RescriptVersions.res
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ let installVersions = async ({rescriptVersion, rescriptCoreVersion}) => {

switch packageManager {
| YarnBerry => await ensureYarnNodeModulesLinker()
| Pnpm => await execCommand("import") // import versions from package-lock.json
| Pnpm =>
let hasPackageLock = Path.join2(Process.cwd(), "package-lock.json")->Fs.existsSync
if hasPackageLock {
await execCommand("import") // import versions from package-lock.json
}
| _ => ()
}

Expand Down