workspace-tools 0.19.3 → 0.19.4
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/CHANGELOG.json +16 -1
- package/CHANGELOG.md +10 -2
- package/lib/paths.d.ts +15 -3
- package/lib/paths.js +28 -7
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Thu, 23 Jun 2022 19:
|
|
5
|
+
"date": "Thu, 23 Jun 2022 19:53:00 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.19.4",
|
|
7
|
+
"version": "0.19.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"comment": "Add findProjectRoot path helper",
|
|
14
|
+
"commit": "5ad6577811656ad23cf567f0996cf9b70d8c23a0"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Thu, 23 Jun 2022 19:10:04 GMT",
|
|
6
21
|
"tag": "workspace-tools_v0.19.3",
|
|
7
22
|
"version": "0.19.3",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu, 23 Jun 2022 19:
|
|
3
|
+
This log was last generated on Thu, 23 Jun 2022 19:53:00 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.19.4
|
|
8
|
+
|
|
9
|
+
Thu, 23 Jun 2022 19:53:00 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Add findProjectRoot path helper (elcraig@microsoft.com)
|
|
14
|
+
|
|
7
15
|
## 0.19.3
|
|
8
16
|
|
|
9
|
-
Thu, 23 Jun 2022 19:10:
|
|
17
|
+
Thu, 23 Jun 2022 19:10:04 GMT
|
|
10
18
|
|
|
11
19
|
### Patches
|
|
12
20
|
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Starting from `cwd`, searches up the directory hierarchy for `pathName
|
|
3
|
-
* @param pathName
|
|
4
|
-
* @param cwd
|
|
2
|
+
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
5
3
|
*/
|
|
6
4
|
export declare function searchUp(pathName: string, cwd: string): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* Starting from `cwd`, searches up the directory hierarchy for `.git`.
|
|
7
|
+
*/
|
|
7
8
|
export declare function findGitRoot(cwd: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Starting from `cwd`, searches up the directory hierarchy for `package.json`.
|
|
11
|
+
*/
|
|
8
12
|
export declare function findPackageRoot(cwd: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Starting from `cwd`, searches up the directory hierarchy for the workspace root,
|
|
15
|
+
* falling back to the git root if no workspace is detected.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findProjectRoot(cwd: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Get the folder containing beachball change files.
|
|
20
|
+
*/
|
|
9
21
|
export declare function getChangePath(cwd: string): string | null;
|
|
10
22
|
export declare function isChildOf(child: string, parent: string): boolean;
|
package/lib/paths.js
CHANGED
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isChildOf = exports.getChangePath = exports.findPackageRoot = exports.findGitRoot = exports.searchUp = void 0;
|
|
6
|
+
exports.isChildOf = exports.getChangePath = exports.findProjectRoot = exports.findPackageRoot = exports.findGitRoot = exports.searchUp = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const getWorkspaceRoot_1 = require("./workspaces/getWorkspaceRoot");
|
|
9
10
|
/**
|
|
10
|
-
* Starting from `cwd`, searches up the directory hierarchy for `pathName
|
|
11
|
-
* @param pathName
|
|
12
|
-
* @param cwd
|
|
11
|
+
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
13
12
|
*/
|
|
14
13
|
function searchUp(pathName, cwd) {
|
|
15
14
|
const root = path_1.default.parse(cwd).root;
|
|
@@ -27,18 +26,40 @@ function searchUp(pathName, cwd) {
|
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
exports.searchUp = searchUp;
|
|
29
|
+
/**
|
|
30
|
+
* Starting from `cwd`, searches up the directory hierarchy for `.git`.
|
|
31
|
+
*/
|
|
30
32
|
function findGitRoot(cwd) {
|
|
31
|
-
return searchUp(
|
|
33
|
+
return searchUp(".git", cwd);
|
|
32
34
|
}
|
|
33
35
|
exports.findGitRoot = findGitRoot;
|
|
36
|
+
/**
|
|
37
|
+
* Starting from `cwd`, searches up the directory hierarchy for `package.json`.
|
|
38
|
+
*/
|
|
34
39
|
function findPackageRoot(cwd) {
|
|
35
|
-
return searchUp(
|
|
40
|
+
return searchUp("package.json", cwd);
|
|
36
41
|
}
|
|
37
42
|
exports.findPackageRoot = findPackageRoot;
|
|
43
|
+
/**
|
|
44
|
+
* Starting from `cwd`, searches up the directory hierarchy for the workspace root,
|
|
45
|
+
* falling back to the git root if no workspace is detected.
|
|
46
|
+
*/
|
|
47
|
+
function findProjectRoot(cwd) {
|
|
48
|
+
let workspaceRoot;
|
|
49
|
+
try {
|
|
50
|
+
workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
|
|
51
|
+
}
|
|
52
|
+
catch (_a) { }
|
|
53
|
+
return workspaceRoot || findGitRoot(cwd);
|
|
54
|
+
}
|
|
55
|
+
exports.findProjectRoot = findProjectRoot;
|
|
56
|
+
/**
|
|
57
|
+
* Get the folder containing beachball change files.
|
|
58
|
+
*/
|
|
38
59
|
function getChangePath(cwd) {
|
|
39
60
|
const gitRoot = findGitRoot(cwd);
|
|
40
61
|
if (gitRoot) {
|
|
41
|
-
return path_1.default.join(gitRoot,
|
|
62
|
+
return path_1.default.join(gitRoot, "change");
|
|
42
63
|
}
|
|
43
64
|
return null;
|
|
44
65
|
}
|