@imksh/create 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/installPackages.js +17 -26
package/package.json
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
|
-
import
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
3
|
|
|
4
4
|
export async function installPackages(targetDir) {
|
|
5
|
-
|
|
5
|
+
let packageManager = "npm";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
let packageManager = "npm";
|
|
7
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
packageManager = "yarn";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
await execa(packageManager, ["install"], {
|
|
19
|
-
cwd: targetDir,
|
|
20
|
-
stdio: "inherit",
|
|
21
|
-
env: process.env,
|
|
22
|
-
preferLocal: false,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
spinner.succeed("Dependencies installed successfully.");
|
|
26
|
-
} catch (error) {
|
|
27
|
-
spinner.fail("Failed to install dependencies.");
|
|
9
|
+
if (userAgent.startsWith("pnpm")) {
|
|
10
|
+
packageManager = "pnpm";
|
|
11
|
+
} else if (userAgent.startsWith("yarn")) {
|
|
12
|
+
packageManager = "yarn";
|
|
13
|
+
}
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
// Resolve absolute path to package manager
|
|
16
|
+
const executable = execSync(`which ${packageManager}`)
|
|
17
|
+
.toString()
|
|
18
|
+
.trim();
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
await execa(executable, ["install"], {
|
|
21
|
+
cwd: targetDir,
|
|
22
|
+
stdio: "inherit",
|
|
23
|
+
env: process.env,
|
|
24
|
+
});
|
|
34
25
|
}
|