aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/turbo-utils/src/getTurboRoot.ts
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2023-11-03 21:25:40 +0800
committer简律纯 <i@jyunko.cn>2023-11-03 21:25:40 +0800
commit9029588590bea8b10451575c5142dcde77ecd1b5 (patch)
tree04cf8aee56c23fd225ff19d340f7cee621d874ef /packages/turbo-utils/src/getTurboRoot.ts
parent94071d7ce16c56641d67d488e2bac6be84ffe731 (diff)
downloadHydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.tar.gz
HydroRoll-9029588590bea8b10451575c5142dcde77ecd1b5.zip
chore: delete useless files
Diffstat (limited to 'packages/turbo-utils/src/getTurboRoot.ts')
-rw-r--r--packages/turbo-utils/src/getTurboRoot.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/packages/turbo-utils/src/getTurboRoot.ts b/packages/turbo-utils/src/getTurboRoot.ts
deleted file mode 100644
index 64a37be..0000000
--- a/packages/turbo-utils/src/getTurboRoot.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { findRootSync } from "@manypkg/find-root";
-import searchUp from "./searchUp";
-import JSON5 from "json5";
-
-interface Options {
- cache?: boolean;
-}
-
-function contentCheck(content: string): boolean {
- const result = JSON5.parse(content);
- return !result.extends;
-}
-
-const configCache: Record<string, string> = {};
-
-function getTurboRoot(cwd?: string, opts?: Options): string | null {
- const cacheEnabled = opts?.cache ?? true;
- const currentDir = cwd || process.cwd();
-
- if (cacheEnabled && configCache[currentDir]) {
- return configCache[currentDir];
- }
-
- // Turborepo root can be determined by a turbo.json without an extends key
- let root = searchUp({
- target: "turbo.json",
- cwd: currentDir,
- contentCheck,
- });
-
- if (!root) {
- try {
- root = findRootSync(currentDir);
- if (!root) {
- return null;
- }
- } catch (err) {
- return null;
- }
- }
-
- if (cacheEnabled) {
- configCache[currentDir] = root;
- }
-
- return root;
-}
-
-export default getTurboRoot;