@theia/process 1.48.0 → 1.48.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.
Files changed (69) hide show
  1. package/README.md +30 -30
  2. package/lib/common/process-common-module.d.ts +3 -3
  3. package/lib/common/process-common-module.js +22 -22
  4. package/lib/common/process-manager-types.d.ts +35 -35
  5. package/lib/common/process-manager-types.js +23 -23
  6. package/lib/common/shell-command-builder.d.ts +49 -49
  7. package/lib/common/shell-command-builder.js +169 -169
  8. package/lib/common/shell-command-builder.slow-spec.d.ts +9 -9
  9. package/lib/common/shell-command-builder.slow-spec.js +404 -404
  10. package/lib/common/shell-quoting.d.ts +91 -91
  11. package/lib/common/shell-quoting.js +145 -145
  12. package/lib/common/shell-quoting.spec.d.ts +1 -1
  13. package/lib/common/shell-quoting.spec.js +170 -170
  14. package/lib/node/dev-null-stream.d.ts +17 -17
  15. package/lib/node/dev-null-stream.js +41 -41
  16. package/lib/node/index.d.ts +6 -6
  17. package/lib/node/index.js +24 -24
  18. package/lib/node/multi-ring-buffer.d.ts +68 -68
  19. package/lib/node/multi-ring-buffer.js +299 -299
  20. package/lib/node/multi-ring-buffer.spec.d.ts +1 -1
  21. package/lib/node/multi-ring-buffer.spec.js +422 -422
  22. package/lib/node/process-backend-module.d.ts +3 -3
  23. package/lib/node/process-backend-module.js +56 -56
  24. package/lib/node/process-manager.d.ts +33 -33
  25. package/lib/node/process-manager.js +102 -102
  26. package/lib/node/process.d.ts +95 -95
  27. package/lib/node/process.js +142 -142
  28. package/lib/node/pseudo-pty.d.ts +22 -22
  29. package/lib/node/pseudo-pty.js +38 -38
  30. package/lib/node/raw-process.d.ts +45 -45
  31. package/lib/node/raw-process.js +104 -104
  32. package/lib/node/raw-process.spec.d.ts +1 -1
  33. package/lib/node/raw-process.spec.js +164 -164
  34. package/lib/node/task-terminal-process.d.ts +10 -10
  35. package/lib/node/task-terminal-process.js +42 -42
  36. package/lib/node/terminal-process.d.ts +60 -60
  37. package/lib/node/terminal-process.js +248 -248
  38. package/lib/node/terminal-process.spec.d.ts +1 -1
  39. package/lib/node/terminal-process.spec.js +103 -103
  40. package/lib/node/test/process-test-container.d.ts +2 -2
  41. package/lib/node/test/process-test-container.js +28 -28
  42. package/lib/node/utils.d.ts +16 -16
  43. package/lib/node/utils.js +77 -77
  44. package/package.json +4 -4
  45. package/src/common/process-common-module.ts +22 -22
  46. package/src/common/process-manager-types.ts +58 -58
  47. package/src/common/shell-command-builder.slow-spec.ts +486 -486
  48. package/src/common/shell-command-builder.ts +187 -187
  49. package/src/common/shell-quoting.spec.ts +176 -176
  50. package/src/common/shell-quoting.ts +236 -236
  51. package/src/common/tests/$weird(),file=name.js +1 -1
  52. package/src/common/tests/white space.js +1 -1
  53. package/src/node/dev-null-stream.ts +47 -47
  54. package/src/node/index.ts +22 -22
  55. package/src/node/multi-ring-buffer.spec.ts +486 -486
  56. package/src/node/multi-ring-buffer.ts +348 -348
  57. package/src/node/process-backend-module.ts +67 -67
  58. package/src/node/process-manager.ts +107 -107
  59. package/src/node/process.ts +207 -207
  60. package/src/node/pseudo-pty.ts +54 -54
  61. package/src/node/raw-process.spec.ts +199 -199
  62. package/src/node/raw-process.ts +156 -156
  63. package/src/node/string-argv.d.ts +21 -21
  64. package/src/node/task-terminal-process.ts +41 -41
  65. package/src/node/terminal-process.spec.ts +121 -121
  66. package/src/node/terminal-process.ts +290 -290
  67. package/src/node/test/process-fork-test.js +22 -22
  68. package/src/node/test/process-test-container.ts +27 -27
  69. package/src/node/utils.ts +79 -79
@@ -1,121 +1,121 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
- import * as chai from 'chai';
17
- import * as process from 'process';
18
- import * as stream from 'stream';
19
- import { createProcessTestContainer } from './test/process-test-container';
20
- import { TerminalProcessFactory } from './terminal-process';
21
- import { IProcessExitEvent, ProcessErrorEvent } from './process';
22
- import { isWindows } from '@theia/core/lib/common/os';
23
-
24
- /**
25
- * Globals
26
- */
27
-
28
- const expect = chai.expect;
29
-
30
- let terminalProcessFactory: TerminalProcessFactory;
31
-
32
- beforeEach(() => {
33
- terminalProcessFactory = createProcessTestContainer().get<TerminalProcessFactory>(TerminalProcessFactory);
34
- });
35
-
36
- describe('TerminalProcess', function (): void {
37
-
38
- this.timeout(20_000);
39
-
40
- it('test error on non existent path', async function (): Promise<void> {
41
- const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
42
- const proc = terminalProcessFactory({ command: '/non-existent' });
43
- proc.onStart(reject);
44
- proc.onError(resolve);
45
- proc.onExit(reject);
46
- });
47
-
48
- expect(error.code).eq('ENOENT');
49
- });
50
-
51
- it('test implicit .exe (Windows only)', async function (): Promise<void> {
52
- const match = /^(.+)\.exe$/.exec(process.execPath);
53
- if (!isWindows || !match) {
54
- this.skip();
55
- }
56
-
57
- const command = match[1];
58
- const args = ['--version'];
59
- const terminal = await new Promise<IProcessExitEvent>((resolve, reject) => {
60
- const proc = terminalProcessFactory({ command, args });
61
- proc.onExit(resolve);
62
- proc.onError(reject);
63
- });
64
-
65
- expect(terminal.code).to.exist;
66
- });
67
-
68
- it('test error on trying to execute a directory', async function (): Promise<void> {
69
- const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
70
- const proc = terminalProcessFactory({ command: __dirname });
71
- proc.onStart(reject);
72
- proc.onError(resolve);
73
- proc.onExit(reject);
74
- });
75
-
76
- if (isWindows) {
77
- // On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
78
- // from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
79
- // probably the best we can get.
80
- expect(error.code).eq('ENOENT');
81
- } else {
82
- expect(error.code).eq('EACCES');
83
- }
84
- });
85
-
86
- it('test exit', async function (): Promise<void> {
87
- const args = ['--version'];
88
- const exit = await new Promise<IProcessExitEvent>((resolve, reject) => {
89
- const proc = terminalProcessFactory({ command: process.execPath, args });
90
- proc.onExit(resolve);
91
- proc.onError(reject);
92
- });
93
-
94
- expect(exit.code).eq(0);
95
- });
96
-
97
- it('test pipe stream', async function (): Promise<void> {
98
- const v = await new Promise<string>((resolve, reject) => {
99
- const args = ['--version'];
100
- const terminalProcess = terminalProcessFactory({ command: process.execPath, args });
101
- terminalProcess.onError(reject);
102
- const outStream = new stream.PassThrough();
103
-
104
- terminalProcess.createOutputStream().pipe(outStream);
105
-
106
- let version = '';
107
- outStream.on('data', data => {
108
- version += data.toString();
109
- });
110
- /* node-pty is not sending 'end' on the stream as it quits
111
- only 'exit' is sent on the terminal process. */
112
- terminalProcess.onExit(() => {
113
- resolve(version.trim());
114
- });
115
- });
116
-
117
- /* Avoid using equal since terminal characters can be inserted at the end. */
118
- expect(v).to.have.string(process.version);
119
- });
120
-
121
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import * as chai from 'chai';
17
+ import * as process from 'process';
18
+ import * as stream from 'stream';
19
+ import { createProcessTestContainer } from './test/process-test-container';
20
+ import { TerminalProcessFactory } from './terminal-process';
21
+ import { IProcessExitEvent, ProcessErrorEvent } from './process';
22
+ import { isWindows } from '@theia/core/lib/common/os';
23
+
24
+ /**
25
+ * Globals
26
+ */
27
+
28
+ const expect = chai.expect;
29
+
30
+ let terminalProcessFactory: TerminalProcessFactory;
31
+
32
+ beforeEach(() => {
33
+ terminalProcessFactory = createProcessTestContainer().get<TerminalProcessFactory>(TerminalProcessFactory);
34
+ });
35
+
36
+ describe('TerminalProcess', function (): void {
37
+
38
+ this.timeout(20_000);
39
+
40
+ it('test error on non existent path', async function (): Promise<void> {
41
+ const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
42
+ const proc = terminalProcessFactory({ command: '/non-existent' });
43
+ proc.onStart(reject);
44
+ proc.onError(resolve);
45
+ proc.onExit(reject);
46
+ });
47
+
48
+ expect(error.code).eq('ENOENT');
49
+ });
50
+
51
+ it('test implicit .exe (Windows only)', async function (): Promise<void> {
52
+ const match = /^(.+)\.exe$/.exec(process.execPath);
53
+ if (!isWindows || !match) {
54
+ this.skip();
55
+ }
56
+
57
+ const command = match[1];
58
+ const args = ['--version'];
59
+ const terminal = await new Promise<IProcessExitEvent>((resolve, reject) => {
60
+ const proc = terminalProcessFactory({ command, args });
61
+ proc.onExit(resolve);
62
+ proc.onError(reject);
63
+ });
64
+
65
+ expect(terminal.code).to.exist;
66
+ });
67
+
68
+ it('test error on trying to execute a directory', async function (): Promise<void> {
69
+ const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
70
+ const proc = terminalProcessFactory({ command: __dirname });
71
+ proc.onStart(reject);
72
+ proc.onError(resolve);
73
+ proc.onExit(reject);
74
+ });
75
+
76
+ if (isWindows) {
77
+ // On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
78
+ // from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
79
+ // probably the best we can get.
80
+ expect(error.code).eq('ENOENT');
81
+ } else {
82
+ expect(error.code).eq('EACCES');
83
+ }
84
+ });
85
+
86
+ it('test exit', async function (): Promise<void> {
87
+ const args = ['--version'];
88
+ const exit = await new Promise<IProcessExitEvent>((resolve, reject) => {
89
+ const proc = terminalProcessFactory({ command: process.execPath, args });
90
+ proc.onExit(resolve);
91
+ proc.onError(reject);
92
+ });
93
+
94
+ expect(exit.code).eq(0);
95
+ });
96
+
97
+ it('test pipe stream', async function (): Promise<void> {
98
+ const v = await new Promise<string>((resolve, reject) => {
99
+ const args = ['--version'];
100
+ const terminalProcess = terminalProcessFactory({ command: process.execPath, args });
101
+ terminalProcess.onError(reject);
102
+ const outStream = new stream.PassThrough();
103
+
104
+ terminalProcess.createOutputStream().pipe(outStream);
105
+
106
+ let version = '';
107
+ outStream.on('data', data => {
108
+ version += data.toString();
109
+ });
110
+ /* node-pty is not sending 'end' on the stream as it quits
111
+ only 'exit' is sent on the terminal process. */
112
+ terminalProcess.onExit(() => {
113
+ resolve(version.trim());
114
+ });
115
+ });
116
+
117
+ /* Avoid using equal since terminal characters can be inserted at the end. */
118
+ expect(v).to.have.string(process.version);
119
+ });
120
+
121
+ });