@sap-ux/project-access 1.35.13 → 1.35.15

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.
@@ -6,10 +6,12 @@ import type { Logger } from '@sap-ux/logger';
6
6
  * @param [options] - optional options
7
7
  * @param [options.cwd] - optional current working directory
8
8
  * @param [options.logger] - optional logger instance
9
+ * @param [options.throwOnError] - optional flag to throw an error if the command exits with a non-zero code, default is false
9
10
  * @returns - stdout of the command
10
11
  */
11
12
  export declare function execNpmCommand(commandArguments: string[], options?: {
12
13
  cwd?: string;
13
14
  logger?: Logger;
15
+ throwOnError?: boolean;
14
16
  }): Promise<string>;
15
17
  //# sourceMappingURL=npm-command.d.ts.map
@@ -9,6 +9,7 @@ const node_child_process_1 = require("node:child_process");
9
9
  * @param [options] - optional options
10
10
  * @param [options.cwd] - optional current working directory
11
11
  * @param [options.logger] - optional logger instance
12
+ * @param [options.throwOnError] - optional flag to throw an error if the command exits with a non-zero code, default is false
12
13
  * @returns - stdout of the command
13
14
  */
14
15
  async function execNpmCommand(commandArguments, options) {
@@ -30,20 +31,30 @@ async function execNpmCommand(commandArguments, options) {
30
31
  spawnProcess.stderr.on('data', (data) => {
31
32
  stdErr += data.toString();
32
33
  });
33
- spawnProcess.on('exit', () => {
34
- if (logger) {
35
- const commandString = `${npmCommand} ${commandArguments.join(' ')}`;
36
- if (stdErr) {
37
- logger.error(`Command '${commandString}' not successful, stderr: ${stdErr}`);
38
- }
34
+ const commandString = `${npmCommand} ${commandArguments.join(' ')}`;
35
+ spawnProcess.on('exit', (code, signal) => {
36
+ if (code === null) {
37
+ logger?.warn(`Command '${commandString}' was killed by signal: ${signal}`);
38
+ }
39
+ else if (code === 0) {
40
+ const stdMessages = [stdOut, stdErr].filter(Boolean).join('\n');
41
+ const output = stdMessages ? `:\n${stdMessages}` : '';
42
+ logger?.info(`Command '${commandString}' successful${output}`);
43
+ }
44
+ else if (options?.throwOnError) {
39
45
  if (stdOut) {
40
- logger.info(`Command '${commandString}' successful, stdout: ${stdOut}`);
46
+ logger?.info(stdOut);
41
47
  }
48
+ reject(new Error(`Command '${commandString}' failed with exit code ${code}. Stderr: ${stdErr}`));
49
+ return;
50
+ }
51
+ else {
52
+ logger?.error(`Command '${commandString}' not successful, stderr: ${stdErr}`);
42
53
  }
43
54
  resolve(stdOut);
44
55
  });
45
56
  spawnProcess.on('error', (error) => {
46
- logger?.error(`Error executing npm command '${npmCommand} ${commandArguments.join(' ')}': ${error}`);
57
+ logger?.error(`Error executing npm command '${commandString}': ${error}`);
47
58
  reject(error);
48
59
  });
49
60
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.35.13",
3
+ "version": "1.35.15",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "semver": "7.7.4",
32
32
  "@sap-ux/i18n": "0.3.9",
33
- "@sap-ux/ui5-config": "0.29.21"
33
+ "@sap-ux/ui5-config": "0.30.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@sap-ux/vocabularies-types": "0.15.0",