Skip to content

Commit 24cb4ac

Browse files
Merge pull request #1122 from bryceosterhaus/master
fix(js-toolkit-core): if run from a workspace, traverse up tree to find client-extension.yaml
2 parents 3952f45 + 736b576 commit 24cb4ac

File tree

2 files changed

+47
-21
lines changed

2 files changed

+47
-21
lines changed

.github/workflows/projects.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on:
2222

2323
env:
2424
CI: true
25-
yarn-cache-name: yarn-cache-1
25+
yarn-cache-name: yarn-cache-10
2626
yarn-cache-path: .yarn
2727

2828
jobs:

projects/js-toolkit/packages/js-toolkit-core/src/project/liferayCli/Project.ts

+46-20
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,24 @@ export default class Project {
6868

6969
let liferayJson: LiferayJson = this._loadLiferayJson();
7070

71-
const clientExtensionYamlPath = this.dir.join('client-extension.yaml')
72-
.asNative;
73-
74-
if (fs.existsSync(clientExtensionYamlPath)) {
75-
try {
76-
const yamlConfig = yaml.load(
77-
fs.readFileSync(
78-
this.dir.join('client-extension.yaml').asNative,
79-
'utf8'
80-
)
81-
);
82-
83-
liferayJson = merge.all([
84-
liferayJson,
85-
this._normalizeClientExtensionYaml(yamlConfig),
86-
]);
87-
}
88-
catch (error) {
89-
if (error.code !== 'ENOENT') {
90-
throw error;
71+
if (self.isWorkspace) {
72+
const clientExtensionYamlPath = this._getClientExtensionYamlPath();
73+
74+
if (fs.existsSync(clientExtensionYamlPath)) {
75+
try {
76+
const yamlConfig = yaml.load(
77+
fs.readFileSync(clientExtensionYamlPath, 'utf8')
78+
);
79+
80+
liferayJson = merge.all([
81+
liferayJson,
82+
this._normalizeClientExtensionYaml(yamlConfig),
83+
]);
84+
}
85+
catch (error) {
86+
if (error.code !== 'ENOENT') {
87+
throw error;
88+
}
9189
}
9290
}
9391
}
@@ -183,6 +181,34 @@ export default class Project {
183181
return isWorkspace;
184182
}
185183

184+
private _getClientExtensionYamlPath(): string {
185+
let dir = this.dir.resolve().asNative;
186+
187+
while (true) {
188+
const clientExtensionYamlPath = path.join(
189+
dir,
190+
'client-extension.yaml'
191+
);
192+
193+
if (fs.existsSync(clientExtensionYamlPath)) {
194+
return clientExtensionYamlPath;
195+
}
196+
197+
const newDir = path.dirname(dir);
198+
199+
if (
200+
newDir === dir ||
201+
fs.existsSync(path.join(dir, 'settings.gradle'))
202+
) {
203+
break;
204+
}
205+
206+
dir = newDir;
207+
}
208+
209+
return '';
210+
}
211+
186212
private _loadLiferayJson(): LiferayJson {
187213
const items: unknown[] = [{}];
188214

0 commit comments

Comments
 (0)