@stacksjs/path 0.74.31 → 0.74.33
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/index.js +17 -7
- package/dist/project.js +16 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32,13 +32,23 @@ import process2 from "process";
|
|
|
32
32
|
// src/project.ts
|
|
33
33
|
import { relative, resolve } from "path";
|
|
34
34
|
import process from "process";
|
|
35
|
+
var cachedCwd;
|
|
36
|
+
var cachedProjectRoot = "";
|
|
35
37
|
function projectPath(filePath = "", options) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
path =
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
let path;
|
|
40
|
+
if (cwd === cachedCwd) {
|
|
41
|
+
path = cachedProjectRoot;
|
|
42
|
+
} else {
|
|
43
|
+
path = cwd;
|
|
44
|
+
while (path.includes("storage")) {
|
|
45
|
+
const parent = resolve(path, "..");
|
|
46
|
+
if (parent === path)
|
|
47
|
+
break;
|
|
48
|
+
path = parent;
|
|
49
|
+
}
|
|
50
|
+
cachedCwd = cwd;
|
|
51
|
+
cachedProjectRoot = path;
|
|
42
52
|
}
|
|
43
53
|
const finalPath = resolve(path, filePath);
|
|
44
54
|
if (options?.relative)
|
|
@@ -583,12 +593,12 @@ function ensureRuntimeDirectories() {
|
|
|
583
593
|
const legacyPath = projectPath(legacy);
|
|
584
594
|
const targetPath = target();
|
|
585
595
|
try {
|
|
586
|
-
mkdirSync(targetPath, { recursive: true });
|
|
587
596
|
const stats = lstatSync(legacyPath, { throwIfNoEntry: false });
|
|
588
597
|
if (!stats) {
|
|
589
598
|
results.push({ legacy: legacyPath, target: targetPath, cleared: true });
|
|
590
599
|
continue;
|
|
591
600
|
}
|
|
601
|
+
mkdirSync(targetPath, { recursive: true });
|
|
592
602
|
if (stats.isSymbolicLink()) {
|
|
593
603
|
const pointsAtTarget = resolve2(dirname(legacyPath), readlinkSync(legacyPath)) === resolve2(targetPath);
|
|
594
604
|
if (!pointsAtTarget) {
|
package/dist/project.js
CHANGED
|
@@ -2,13 +2,23 @@
|
|
|
2
2
|
// src/project.ts
|
|
3
3
|
import { relative, resolve } from "path";
|
|
4
4
|
import process from "process";
|
|
5
|
+
var cachedCwd;
|
|
6
|
+
var cachedProjectRoot = "";
|
|
5
7
|
function projectPath(filePath = "", options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
path =
|
|
8
|
+
const cwd = process.cwd();
|
|
9
|
+
let path;
|
|
10
|
+
if (cwd === cachedCwd) {
|
|
11
|
+
path = cachedProjectRoot;
|
|
12
|
+
} else {
|
|
13
|
+
path = cwd;
|
|
14
|
+
while (path.includes("storage")) {
|
|
15
|
+
const parent = resolve(path, "..");
|
|
16
|
+
if (parent === path)
|
|
17
|
+
break;
|
|
18
|
+
path = parent;
|
|
19
|
+
}
|
|
20
|
+
cachedCwd = cwd;
|
|
21
|
+
cachedProjectRoot = path;
|
|
12
22
|
}
|
|
13
23
|
const finalPath = resolve(path, filePath);
|
|
14
24
|
if (options?.relative)
|