@ruan-cat/utils 4.20.0 → 4.21.0

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/README.md CHANGED
@@ -14,3 +14,29 @@ dir:
14
14
  <!-- /automd -->
15
15
 
16
16
  这是阮喵喵开发的工具包,提供了一些工具函数。
17
+
18
+ ## Install
19
+
20
+ <!-- automd:pm-install name="@ruan-cat/utils" -->
21
+
22
+ ```sh
23
+ # ✨ Auto-detect
24
+ npx nypm install @ruan-cat/utils
25
+
26
+ # npm
27
+ npm install @ruan-cat/utils
28
+
29
+ # yarn
30
+ yarn add @ruan-cat/utils
31
+
32
+ # pnpm
33
+ pnpm add @ruan-cat/utils
34
+
35
+ # bun
36
+ bun install @ruan-cat/utils
37
+
38
+ # deno
39
+ deno install npm:@ruan-cat/utils
40
+ ```
41
+
42
+ <!-- /automd -->
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  defPrintCurrentCommand: () => defPrintCurrentCommand,
34
34
  definePromiseTasks: () => definePromiseTasks,
35
35
  executePromiseTasks: () => executePromiseTasks,
36
+ findMonorepoRoot: () => findMonorepoRoot,
36
37
  generateSimpleAsyncTask: () => generateSimpleAsyncTask,
37
38
  generateSpawnSync: () => generateSpawnSync,
38
39
  initFlag: () => initFlag,
@@ -54,8 +55,8 @@ var import_node_child_process = require("child_process");
54
55
  // src/simple-promise-tools.ts
55
56
  function generateSimpleAsyncTask(func) {
56
57
  return function(...args) {
57
- return new Promise((resolve, reject) => {
58
- resolve(func(...args));
58
+ return new Promise((resolve2, reject) => {
59
+ resolve2(func(...args));
59
60
  });
60
61
  };
61
62
  }
@@ -2787,6 +2788,20 @@ var import_lodash_es2 = require("lodash-es");
2787
2788
  function pathChange2(path) {
2788
2789
  return path.replace(/\\/g, "/");
2789
2790
  }
2791
+ function findMonorepoRoot(startDir = process.cwd()) {
2792
+ let currentDir = (0, import_node_path.resolve)(startDir);
2793
+ const fileSystemRoot = (0, import_node_path.parse)(currentDir).root;
2794
+ while (true) {
2795
+ const workspaceConfigPath = (0, import_node_path.join)(currentDir, "pnpm-workspace.yaml");
2796
+ if (fs.existsSync(workspaceConfigPath)) {
2797
+ return currentDir;
2798
+ }
2799
+ if (currentDir === fileSystemRoot) {
2800
+ return null;
2801
+ }
2802
+ currentDir = (0, import_node_path.dirname)(currentDir);
2803
+ }
2804
+ }
2790
2805
  function isMonorepoProject() {
2791
2806
  const workspaceConfigPath = (0, import_node_path.join)(process.cwd(), "pnpm-workspace.yaml");
2792
2807
  if (!fs.existsSync(workspaceConfigPath)) {
@@ -2821,6 +2836,7 @@ function isMonorepoProject() {
2821
2836
  defPrintCurrentCommand,
2822
2837
  definePromiseTasks,
2823
2838
  executePromiseTasks,
2839
+ findMonorepoRoot,
2824
2840
  generateSimpleAsyncTask,
2825
2841
  generateSpawnSync,
2826
2842
  initFlag,