@stacksjs/path 0.74.31 → 0.74.32

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 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
- let path = process.cwd();
37
- while (path.includes("storage")) {
38
- const parent = resolve(path, "..");
39
- if (parent === path)
40
- break;
41
- path = parent;
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)
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
- let path = process.cwd();
7
- while (path.includes("storage")) {
8
- const parent = resolve(path, "..");
9
- if (parent === path)
10
- break;
11
- path = parent;
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)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/path",
3
3
  "type": "module",
4
- "version": "0.74.31",
4
+ "version": "0.74.32",
5
5
  "description": "The Stacks path.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [