@stryke/path 0.8.2 → 0.9.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.
|
@@ -3,24 +3,36 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.WORKSPACE_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = void 0;
|
|
7
|
+
exports.getProjectRoot = getProjectRoot;
|
|
8
|
+
exports.getWorkspaceRoot = getWorkspaceRoot;
|
|
9
|
+
exports.isProjectRoot = isProjectRoot;
|
|
10
|
+
exports.isWorkspaceRoot = isWorkspaceRoot;
|
|
7
11
|
var _configTools = require("@storm-software/config-tools");
|
|
8
12
|
var _getParentPath = require("./get-parent-path.cjs");
|
|
9
13
|
var _isRootDir = require("./is-root-dir.cjs");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const WORKSPACE_ROOT_CONTENT = exports.WORKSPACE_ROOT_CONTENT = ["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "nx.json", "knip.json", "pnpm-workspace.yaml", "LICENSE", ".all-contributorsrc", ".whitesource", "syncpack.config.js", "syncpack.json", "socket.yaml", "lefthook.yaml", ".npmrc", ".log4brains.yml", ".huskyrc", ".husky", ".lintstagedrc", ".commitlintrc", "lefthook.yml", ".github", ".nx", ".vscode", "patches"],
|
|
15
|
+
PROJECT_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = ["project.json", "package.json", ".storm"];
|
|
16
|
+
function getWorkspaceRoot(o = process.cwd()) {
|
|
17
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
|
|
18
|
+
const t = (0, _configTools.findWorkspaceRootSafe)(o);
|
|
19
|
+
if (t) return t;
|
|
20
|
+
let r = (0, _getParentPath.getParentPath)(WORKSPACE_ROOT_CONTENT, o);
|
|
21
|
+
if (r) return r;
|
|
22
|
+
for (r = o; r && !(0, _isRootDir.isSystemRoot)(r);) if (r = (0, _getParentPath.getParentPath)("storm-workspace.json", r, {
|
|
23
|
+
skipCwd: !0
|
|
24
|
+
}), r) return r;
|
|
25
|
+
return o;
|
|
26
|
+
}
|
|
27
|
+
function isWorkspaceRoot(o = process.cwd()) {
|
|
28
|
+
const t = getWorkspaceRoot(o);
|
|
29
|
+
return t ? t === o : !1;
|
|
30
|
+
}
|
|
31
|
+
function getProjectRoot(o = process.cwd()) {
|
|
32
|
+
const t = (0, _getParentPath.getParentPath)(PROJECT_ROOT_CONTENT, o);
|
|
33
|
+
return t || o;
|
|
34
|
+
}
|
|
35
|
+
function isProjectRoot(o = process.cwd()) {
|
|
36
|
+
const t = getProjectRoot(o);
|
|
37
|
+
return t ? t === o : !1;
|
|
38
|
+
}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
+
export declare const WORKSPACE_ROOT_CONTENT: string[];
|
|
2
|
+
export declare const PROJECT_ROOT_CONTENT: string[];
|
|
1
3
|
/**
|
|
2
4
|
* Get the workspace root path
|
|
3
5
|
*
|
|
4
6
|
* @param dir - A directory to start the search from
|
|
5
7
|
* @returns The workspace root path
|
|
6
8
|
*/
|
|
7
|
-
export declare
|
|
9
|
+
export declare function getWorkspaceRoot(dir?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Check if the given directory is the workspace root
|
|
12
|
+
*
|
|
13
|
+
* @param dir - A directory to check
|
|
14
|
+
* @returns True if the directory is the workspace root, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare function isWorkspaceRoot(dir?: string): boolean;
|
|
8
17
|
/**
|
|
9
18
|
* Get the project root path
|
|
10
19
|
*
|
|
11
20
|
* @param dir - A directory to start the search from
|
|
12
21
|
* @returns The project root path
|
|
13
22
|
*/
|
|
14
|
-
export declare
|
|
23
|
+
export declare function getProjectRoot(dir?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the given directory is the project root
|
|
26
|
+
*
|
|
27
|
+
* @param dir - A directory to check
|
|
28
|
+
* @returns True if the directory is the project root, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
export declare function isProjectRoot(dir?: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findWorkspaceRootSafe as
|
|
1
|
+
import{findWorkspaceRootSafe as e}from"@storm-software/config-tools";import{getParentPath as s}from"./get-parent-path";import{isSystemRoot as n}from"./is-root-dir";export const WORKSPACE_ROOT_CONTENT=["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock","nx.json","knip.json","pnpm-workspace.yaml","LICENSE",".all-contributorsrc",".whitesource","syncpack.config.js","syncpack.json","socket.yaml","lefthook.yaml",".npmrc",".log4brains.yml",".huskyrc",".husky",".lintstagedrc",".commitlintrc","lefthook.yml",".github",".nx",".vscode","patches"],PROJECT_ROOT_CONTENT=["project.json","package.json",".storm"];export function getWorkspaceRoot(o=process.cwd()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;const t=e(o);if(t)return t;let r=s(WORKSPACE_ROOT_CONTENT,o);if(r)return r;for(r=o;r&&!n(r);)if(r=s("storm-workspace.json",r,{skipCwd:!0}),r)return r;return o}export function isWorkspaceRoot(o=process.cwd()){const t=getWorkspaceRoot(o);return t?t===o:!1}export function getProjectRoot(o=process.cwd()){const t=s(PROJECT_ROOT_CONTENT,o);return t||o}export function isProjectRoot(o=process.cwd()){const t=getProjectRoot(o);return t?t===o:!1}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/path",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
|
|
6
6
|
"repository": {
|
|
@@ -259,5 +259,6 @@
|
|
|
259
259
|
},
|
|
260
260
|
"main": "./dist/index.cjs",
|
|
261
261
|
"module": "./dist/index.mjs",
|
|
262
|
-
"types": "./dist/index.d.ts"
|
|
262
|
+
"types": "./dist/index.d.ts",
|
|
263
|
+
"gitHead": "4052d0819f6c27c02af4ccd7460b5cd28c36f5c4"
|
|
263
264
|
}
|