@emberkit/cli 0.5.1 → 0.5.2
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/dist/utils/filesystem.js +10 -12
- package/package.json +1 -1
package/dist/utils/filesystem.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync as fsReadFileSync, writeFileSync as fsWriteFileSync } from "fs";
|
|
2
|
+
import { resolve, dirname } from "path";
|
|
3
|
+
import { execSync } from "child_process";
|
|
4
|
+
import { platform } from "os";
|
|
1
5
|
export { generate, toPascalCase, toKebabCase } from "./generator.js";
|
|
2
6
|
export function ensureDirSync(dirPath) {
|
|
3
|
-
const { mkdirSync, existsSync } = require("fs");
|
|
4
7
|
if (!existsSync(dirPath)) {
|
|
5
8
|
mkdirSync(dirPath, { recursive: true });
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
11
|
export function readFileSync(filePath) {
|
|
9
|
-
|
|
10
|
-
return readFileSync(filePath, "utf-8");
|
|
12
|
+
return fsReadFileSync(filePath, "utf-8");
|
|
11
13
|
}
|
|
12
14
|
export function writeFileSync(filePath, content, options) {
|
|
13
|
-
const
|
|
14
|
-
const dir = require("path").dirname(filePath);
|
|
15
|
+
const dir = dirname(filePath);
|
|
15
16
|
ensureDirSync(dir);
|
|
16
|
-
|
|
17
|
+
fsWriteFileSync(filePath, content, options ?? { encoding: "utf-8" });
|
|
17
18
|
}
|
|
18
19
|
export function fileExists(filePath) {
|
|
19
|
-
const { existsSync } = require("fs");
|
|
20
20
|
return existsSync(filePath);
|
|
21
21
|
}
|
|
22
22
|
export function resolvePath(...segments) {
|
|
23
|
-
return
|
|
23
|
+
return resolve(...segments);
|
|
24
24
|
}
|
|
25
25
|
export function getPackageManager() {
|
|
26
26
|
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
@@ -30,16 +30,14 @@ export function getPackageManager() {
|
|
|
30
30
|
return "yarn";
|
|
31
31
|
if (userAgent.startsWith("npm"))
|
|
32
32
|
return "npm";
|
|
33
|
-
const { existsSync } = require("fs");
|
|
34
|
-
const { platform } = require("os");
|
|
35
33
|
try {
|
|
36
34
|
if (platform() === "win32") {
|
|
37
|
-
|
|
35
|
+
const localAppData = process.env.LOCALAPPDATA ?? "";
|
|
36
|
+
if (existsSync("C:\\Program Files\\pnpm\\pnpm.exe") || existsSync(localAppData + "\\pnpm\\pnpm.exe")) {
|
|
38
37
|
return "pnpm";
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
else {
|
|
42
|
-
const { execSync } = require("child_process");
|
|
43
41
|
execSync("pnpm --version", { stdio: "ignore" });
|
|
44
42
|
return "pnpm";
|
|
45
43
|
}
|