@pnpm/workspace.root-finder 1000.1.3

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2026 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @pnpm/find-workspace-dir
2
+
3
+ > Finds the root of a pnpm workspace
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@pnpm/find-workspace-dir.svg)](https://www.npmjs.com/package/@pnpm/find-workspace-dir)
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ pnpm add @pnpm/find-workspace-dir
11
+ ```
12
+
13
+ ## License
14
+
15
+ MIT
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function findWorkspaceDir(cwd: string): Promise<string | undefined>;
package/lib/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { PnpmError } from '@pnpm/error';
4
+ import { findUp } from 'find-up';
5
+ const WORKSPACE_DIR_ENV_VAR = 'NPM_CONFIG_WORKSPACE_DIR';
6
+ const WORKSPACE_MANIFEST_FILENAME = 'pnpm-workspace.yaml';
7
+ const INVALID_WORKSPACE_MANIFEST_FILENAME = [
8
+ 'pnpm-workspaces.yaml',
9
+ 'pnpm-workspaces.yml',
10
+ 'pnpm-workspace.yml',
11
+ '.pnpm-workspace.yaml',
12
+ '.pnpm-workspace.yml',
13
+ '.pnpm-workspaces.yaml',
14
+ '.pnpm-workspaces.yml',
15
+ ];
16
+ export async function findWorkspaceDir(cwd) {
17
+ const workspaceManifestDirEnvVar = process.env[WORKSPACE_DIR_ENV_VAR] ?? process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
18
+ const workspaceManifestLocation = workspaceManifestDirEnvVar
19
+ ? path.join(workspaceManifestDirEnvVar, WORKSPACE_MANIFEST_FILENAME)
20
+ : await findUp([WORKSPACE_MANIFEST_FILENAME, ...INVALID_WORKSPACE_MANIFEST_FILENAME], { cwd: await getRealPath(cwd) });
21
+ if (workspaceManifestLocation && path.basename(workspaceManifestLocation) !== WORKSPACE_MANIFEST_FILENAME) {
22
+ throw new PnpmError('BAD_WORKSPACE_MANIFEST_NAME', `The workspace manifest file should be named "pnpm-workspace.yaml". File found: ${workspaceManifestLocation}`);
23
+ }
24
+ return workspaceManifestLocation && path.dirname(workspaceManifestLocation);
25
+ }
26
+ async function getRealPath(path) {
27
+ return new Promise((resolve) => {
28
+ // We need to resolve the real native path for case-insensitive file systems.
29
+ // For example, we can access file as C:\Code\Project as well as c:\code\projects
30
+ // Without this we can face a problem when try to install packages with -w flag,
31
+ // when root dir is using c:\code\projects but packages were found by C:\Code\Project
32
+ fs.realpath.native(path, function (err, resolvedPath) {
33
+ resolve(err !== null ? path : resolvedPath);
34
+ });
35
+ });
36
+ }
37
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@pnpm/workspace.root-finder",
3
+ "version": "1000.1.3",
4
+ "description": "Finds the root of a pnpm workspace",
5
+ "keywords": [
6
+ "pnpm",
7
+ "pnpm11"
8
+ ],
9
+ "license": "MIT",
10
+ "funding": "https://opencollective.com/pnpm",
11
+ "repository": "https://github.com/pnpm/pnpm/tree/main/workspace/root-finder",
12
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/workspace/root-finder#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/pnpm/pnpm/issues"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/index.d.ts",
19
+ "exports": {
20
+ ".": "./lib/index.js"
21
+ },
22
+ "files": [
23
+ "lib",
24
+ "!*.map"
25
+ ],
26
+ "dependencies": {
27
+ "find-up": "^7.0.0",
28
+ "@pnpm/error": "1000.0.5"
29
+ },
30
+ "devDependencies": {
31
+ "@pnpm/workspace.root-finder": "1000.1.3"
32
+ },
33
+ "engines": {
34
+ "node": ">=22.13"
35
+ },
36
+ "jest": {
37
+ "preset": "@pnpm/jest-config"
38
+ },
39
+ "scripts": {
40
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
41
+ "_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
42
+ "test": "pnpm run compile && pnpm run _test",
43
+ "compile": "tsgo --build && pnpm run lint --fix"
44
+ }
45
+ }