@pnp/cli-microsoft365 6.1.0-beta.d3a109a → 6.1.0-beta.d7b6439

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.
Files changed (2) hide show
  1. package/dist/utils/pid.js +31 -15
  2. package/package.json +1 -1
package/dist/utils/pid.js CHANGED
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pid = void 0;
4
- const os = require("os");
5
- const fs = require("fs");
6
4
  const child_process_1 = require("child_process");
5
+ const fs = require("fs");
6
+ const os = require("os");
7
7
  const cache_1 = require("./cache");
8
8
  function getProcessNameOnMacOs(pid) {
9
- const stdout = (0, child_process_1.execSync)(`ps -o comm= ${pid}`, { encoding: 'utf8' });
10
- return stdout.trim();
9
+ const res = (0, child_process_1.spawnSync)('ps', ['-o', 'comm=', pid.toString()], { encoding: 'utf8' });
10
+ if (res.error || res.stderr) {
11
+ return undefined;
12
+ }
13
+ else {
14
+ return res.stdout.trim();
15
+ }
11
16
  }
12
17
  function getProcessNameOnLinux(pid) {
13
18
  if (!fs.existsSync(`/proc/${pid}/stat`)) {
@@ -19,8 +24,24 @@ function getProcessNameOnLinux(pid) {
19
24
  return procName;
20
25
  }
21
26
  function getProcessNameOnWindows(pid) {
22
- const stdout = (0, child_process_1.execSync)(`wmic PROCESS where ProcessId=${pid} get Caption | find /V "Caption"`, { encoding: 'utf8' });
23
- return stdout.trim();
27
+ const findProcess = (0, child_process_1.spawnSync)('wmic', ['PROCESS', 'where', `ProcessId=${pid}`, 'get', 'Caption'], { encoding: 'utf8' });
28
+ if (findProcess.error || findProcess.stderr) {
29
+ return undefined;
30
+ }
31
+ else {
32
+ const getPid = (0, child_process_1.spawnSync)('find', ['/V', '"Caption"'], {
33
+ encoding: 'utf8',
34
+ input: findProcess.stdout,
35
+ // must include or passing quoted "Caption" will fail
36
+ windowsVerbatimArguments: true
37
+ });
38
+ if (getPid.error || getPid.stderr) {
39
+ return undefined;
40
+ }
41
+ else {
42
+ return getPid.stdout.trim();
43
+ }
44
+ }
24
45
  }
25
46
  exports.pid = {
26
47
  getProcessName(pid) {
@@ -40,16 +61,11 @@ exports.pid = {
40
61
  getPidName = getProcessNameOnLinux;
41
62
  }
42
63
  if (getPidName) {
43
- try {
44
- processName = getPidName(pid);
45
- if (processName) {
46
- cache_1.cache.setValue(pid.toString(), processName);
47
- }
48
- return processName;
49
- }
50
- catch (_a) {
51
- return undefined;
64
+ processName = getPidName(pid);
65
+ if (processName) {
66
+ cache_1.cache.setValue(pid.toString(), processName);
52
67
  }
68
+ return processName;
53
69
  }
54
70
  return undefined;
55
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.1.0-beta.d3a109a",
3
+ "version": "6.1.0-beta.d7b6439",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",