greybel-mock-environment 2.3.3 → 2.4.0
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/fs.js +1 -1
- package/dist/types/device.d.ts +1 -1
- package/dist/types/device.js +4 -2
- package/dist/types/process.d.ts +13 -7
- package/dist/types/process.js +8 -7
- package/package.json +1 -1
package/dist/fs.js
CHANGED
package/dist/types/device.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class Device {
|
|
|
54
54
|
createUserFolder(userName: string): boolean;
|
|
55
55
|
isAnyProcessActive(): boolean;
|
|
56
56
|
isRootProcessActive(): boolean;
|
|
57
|
-
addProcess(options: Omit<ProcessOptions, 'pid'>):
|
|
57
|
+
addProcess(options: Omit<ProcessOptions, 'pid'>): number;
|
|
58
58
|
removeProcess(pid: number): boolean;
|
|
59
59
|
addGroup(userName: string, groupName: string): boolean;
|
|
60
60
|
removeGroup(userName: string, groupName: string): boolean;
|
package/dist/types/device.js
CHANGED
|
@@ -67,7 +67,8 @@ var Device = /** @class */ (function () {
|
|
|
67
67
|
owner: this.users.get('root'),
|
|
68
68
|
command: 'kernel_task',
|
|
69
69
|
protected: true
|
|
70
|
-
})
|
|
70
|
+
});
|
|
71
|
+
this.addProcess({
|
|
71
72
|
owner: this.users.get('root'),
|
|
72
73
|
command: 'Xorg',
|
|
73
74
|
protected: true
|
|
@@ -255,12 +256,13 @@ var Device = /** @class */ (function () {
|
|
|
255
256
|
protected: options.protected
|
|
256
257
|
});
|
|
257
258
|
this.processes.set(pid, process);
|
|
258
|
-
return
|
|
259
|
+
return pid;
|
|
259
260
|
};
|
|
260
261
|
Device.prototype.removeProcess = function (pid) {
|
|
261
262
|
if (this.processes.has(pid)) {
|
|
262
263
|
var process_4 = this.processes.get(pid);
|
|
263
264
|
if (!process_4.protected) {
|
|
265
|
+
process_4.kill();
|
|
264
266
|
this.processes.delete(pid);
|
|
265
267
|
return true;
|
|
266
268
|
}
|
package/dist/types/process.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { User } from './user';
|
|
2
|
-
export
|
|
2
|
+
export interface ProcessRef {
|
|
3
|
+
exit(): void;
|
|
4
|
+
}
|
|
5
|
+
export interface ProcessOptions {
|
|
3
6
|
owner: User;
|
|
4
7
|
pid: number;
|
|
5
8
|
command: string;
|
|
6
9
|
protected?: boolean;
|
|
10
|
+
ref?: ProcessRef;
|
|
7
11
|
}
|
|
8
12
|
export declare class Process {
|
|
9
|
-
owner: User;
|
|
10
|
-
pid: number;
|
|
11
|
-
cpu: number;
|
|
12
|
-
mem: number;
|
|
13
|
-
command: string;
|
|
14
|
-
protected: boolean;
|
|
13
|
+
readonly owner: User;
|
|
14
|
+
readonly pid: number;
|
|
15
|
+
readonly cpu: number;
|
|
16
|
+
readonly mem: number;
|
|
17
|
+
readonly command: string;
|
|
18
|
+
readonly protected: boolean;
|
|
19
|
+
readonly ref: ProcessRef | null;
|
|
15
20
|
constructor(options: ProcessOptions);
|
|
21
|
+
kill(): void;
|
|
16
22
|
}
|
package/dist/types/process.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Process =
|
|
3
|
+
exports.Process = void 0;
|
|
4
4
|
var utils_1 = require("../utils");
|
|
5
|
-
var ProcessOptions = /** @class */ (function () {
|
|
6
|
-
function ProcessOptions() {
|
|
7
|
-
}
|
|
8
|
-
return ProcessOptions;
|
|
9
|
-
}());
|
|
10
|
-
exports.ProcessOptions = ProcessOptions;
|
|
11
5
|
var Process = /** @class */ (function () {
|
|
12
6
|
function Process(options) {
|
|
7
|
+
var _a;
|
|
13
8
|
this.owner = options.owner;
|
|
14
9
|
this.pid = options.pid;
|
|
15
10
|
this.cpu = (0, utils_1.getRandom)(2, 15);
|
|
16
11
|
this.mem = (0, utils_1.getRandom)(5, 33);
|
|
17
12
|
this.command = options.command;
|
|
18
13
|
this.protected = options.protected;
|
|
14
|
+
this.ref = (_a = options.ref) !== null && _a !== void 0 ? _a : null;
|
|
19
15
|
}
|
|
16
|
+
Process.prototype.kill = function () {
|
|
17
|
+
if (this.ref !== null) {
|
|
18
|
+
this.ref.exit();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
20
21
|
return Process;
|
|
21
22
|
}());
|
|
22
23
|
exports.Process = Process;
|