@sap-ux/project-access 1.35.1 → 1.35.2
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/cap.js +17 -13
- package/package.json +1 -1
package/dist/project/cap.js
CHANGED
|
@@ -567,9 +567,12 @@ async function loadGlobalCdsModule() {
|
|
|
567
567
|
globalCdsModulePromise =
|
|
568
568
|
globalCdsModulePromise ??
|
|
569
569
|
new Promise((resolve, reject) => {
|
|
570
|
-
return
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
return getCdsEnvData().then((data) => {
|
|
571
|
+
// Handle output of `cds env --json`
|
|
572
|
+
const home = data['_home_cds-dk'];
|
|
573
|
+
if (home) {
|
|
574
|
+
// "@sap/cds" module is inside node_modules of "@sap/cds-dk"
|
|
575
|
+
resolve((0, module_loader_1.loadModuleFromProject)((0, node_path_1.join)(home, 'node_modules', '@sap', 'cds'), '@sap/cds'));
|
|
573
576
|
}
|
|
574
577
|
else {
|
|
575
578
|
reject(new Error('Can not find global installation of module @sap/cds, which should be part of @sap/cds-dk'));
|
|
@@ -585,26 +588,27 @@ function clearGlobalCdsModulePromiseCache() {
|
|
|
585
588
|
globalCdsModulePromise = undefined;
|
|
586
589
|
}
|
|
587
590
|
/**
|
|
588
|
-
* Get cds information, which includes
|
|
591
|
+
* Get cds environment information, which includes the home path of cds-dk module.
|
|
589
592
|
*
|
|
590
|
-
* @param [cwd] - optional folder in which cds --
|
|
591
|
-
* @returns - result of call 'cds --
|
|
593
|
+
* @param [cwd] - optional folder in which cds env --json should be executed
|
|
594
|
+
* @returns - result of call 'cds env --json'
|
|
592
595
|
*/
|
|
593
|
-
async function
|
|
596
|
+
async function getCdsEnvData(cwd) {
|
|
594
597
|
return new Promise((resolve, reject) => {
|
|
595
598
|
let out = '';
|
|
596
|
-
|
|
599
|
+
// call 'cds env --json'
|
|
600
|
+
const cdsVersionInfo = (0, node_child_process_1.spawn)('cds', ['env', '--json'], { cwd, shell: true });
|
|
597
601
|
cdsVersionInfo.stdout.on('data', (data) => {
|
|
598
602
|
out += data.toString();
|
|
599
603
|
});
|
|
600
604
|
cdsVersionInfo.on('close', () => {
|
|
601
605
|
if (out) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
+
try {
|
|
607
|
+
resolve(JSON.parse(out));
|
|
608
|
+
}
|
|
609
|
+
catch (e) {
|
|
610
|
+
reject(new Error(`Unexpected output of "cds env --json": ${e.message}`));
|
|
606
611
|
}
|
|
607
|
-
resolve(versions);
|
|
608
612
|
}
|
|
609
613
|
else {
|
|
610
614
|
reject(new Error('Module path not found'));
|