occam-open-cli 5.1.1 → 5.2.1

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.
@@ -1,16 +1,38 @@
1
1
  "use strict";
2
2
 
3
+ const { characters } = require("necessary");
4
+
5
+ const { execute } = require("../utilities/shell");
3
6
  const { EMPTY_STRING } = require("../constants");
4
7
  const { retrieveShellCommands } = require("../configuration");
5
8
 
9
+ const { DASH_CHARACTER } = characters;
10
+
6
11
  function executeShellCommandsOperation(proceed, abort, context) {
7
- const { success } = context;
12
+ const { success, releaseName } = context;
8
13
 
9
14
  if (success) {
10
- const shellCommands = retrieveShellCommands();
15
+ let shellCommands = retrieveShellCommands();
11
16
 
12
17
  if (shellCommands !== EMPTY_STRING) {
13
- debugger
18
+ shellCommands = shellCommands.replace(/{packageName}/, releaseName); ///
19
+
20
+ const output = execute(shellCommands),
21
+ outputs = output.split(/\n/),
22
+ outputsLength = outputs.length;
23
+
24
+ if (outputsLength > 0) {
25
+ const { messages } = context,
26
+ message = DASH_CHARACTER; //
27
+
28
+ messages.push(message);
29
+
30
+ outputs.forEach((output) => {
31
+ const message = output; ///
32
+
33
+ messages.push(message);
34
+ });
35
+ }
14
36
  }
15
37
  }
16
38
 
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ const childProcess = require("child_process");
4
+
5
+ const { encodings } = require("necessary");
6
+ const { trimTrailingCarriageReturn } = require("./string");
7
+
8
+ const { UTF_8_ENCODING } = encodings;
9
+
10
+ function execute(shellCommands) {
11
+ let output;
12
+
13
+ try {
14
+ const stdio = [],
15
+ encoding = UTF_8_ENCODING, ///
16
+ options = {
17
+ stdio,
18
+ encoding
19
+ };
20
+
21
+ output = childProcess.execSync(shellCommands, options);
22
+
23
+ output = trimTrailingCarriageReturn(output); ///
24
+ } catch (error) {
25
+ output = error; ///
26
+ }
27
+
28
+ return output;
29
+ }
30
+
31
+ module.exports = {
32
+ execute
33
+ };
@@ -8,6 +8,13 @@ function trimTrailingSlash(string) {
8
8
  return string;
9
9
  }
10
10
 
11
+ function trimTrailingCarriageReturn(string) {
12
+ string = string.replace(/\n$/, EMPTY_STRING); ///
13
+
14
+ return string;
15
+ }
16
+
11
17
  module.exports = {
12
- trimTrailingSlash
18
+ trimTrailingSlash,
19
+ trimTrailingCarriageReturn
13
20
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "occam-open-cli",
3
3
  "author": "James Smith",
4
- "version": "5.1.1",
4
+ "version": "5.2.1",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/occam-open-cli",
7
7
  "description": "Occam's command line package management tool.",