@phren/cli 0.1.9 → 0.1.10
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/dist/project-locator.js +23 -1
- package/package.json +1 -1
package/dist/project-locator.js
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { debugLog, homeDir, homePath } from "./shared.js";
|
|
3
|
+
import { debugLog, homeDir, homePath, findPhrenPath } from "./shared.js";
|
|
4
4
|
import { errorMessage } from "./utils.js";
|
|
5
5
|
const DEFAULT_SEARCH_PATHS = [
|
|
6
6
|
homeDir(),
|
|
7
7
|
homePath("Sites"),
|
|
8
8
|
homePath("Projects"),
|
|
9
|
+
homePath("projects"),
|
|
9
10
|
homePath("Code"),
|
|
11
|
+
homePath("code"),
|
|
10
12
|
homePath("dev"),
|
|
13
|
+
homePath("src"),
|
|
14
|
+
homePath("repos"),
|
|
15
|
+
homePath("workspace"),
|
|
11
16
|
];
|
|
12
17
|
export function findProjectDir(name) {
|
|
18
|
+
// First check the project's registered sourcePath in phren.project.yaml
|
|
19
|
+
try {
|
|
20
|
+
const phrenPath = findPhrenPath();
|
|
21
|
+
if (phrenPath) {
|
|
22
|
+
const yamlPath = path.join(phrenPath, name, "phren.project.yaml");
|
|
23
|
+
if (fs.existsSync(yamlPath)) {
|
|
24
|
+
const content = fs.readFileSync(yamlPath, "utf-8");
|
|
25
|
+
const match = content.match(/^sourcePath:\s*(.+)$/m);
|
|
26
|
+
if (match) {
|
|
27
|
+
const sp = match[1].trim();
|
|
28
|
+
if (fs.existsSync(sp) && fs.statSync(sp).isDirectory())
|
|
29
|
+
return sp;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch { /* fall through to search paths */ }
|
|
13
35
|
const extra = process.env.PROJECTS_DIR ? [process.env.PROJECTS_DIR] : [];
|
|
14
36
|
for (const base of [...extra, ...DEFAULT_SEARCH_PATHS]) {
|
|
15
37
|
const candidate = path.join(base, name);
|