brsh 2.5.3 → 2.5.4
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/CHANGELOG.md +7 -0
- package/dist/shell.es.js +10 -6
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +3 -3
- package/dist/shell.min.js.map +1 -1
- package/dist/terminal.es.js +10 -6
- package/dist/terminal.es.js.map +1 -1
- package/dist/terminal.min.js +3 -3
- package/dist/terminal.min.js.map +1 -1
- package/index.js +7 -1
- package/lib/Command.js +2 -1
- package/lib/InteractiveCommand.js +2 -2
- package/lib/local/LocalCommand.js +1 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -34,6 +34,12 @@ class Shell extends EventEmitter {
|
|
|
34
34
|
onFsChange: typeof onFsChange === 'function' ? onFsChange : null
|
|
35
35
|
}));
|
|
36
36
|
|
|
37
|
+
this._readonlyContext = Object.freeze({
|
|
38
|
+
getVar: (v) => this.context.getVar(v),
|
|
39
|
+
getAlias: (a) => this.context.getAlias(a),
|
|
40
|
+
getCommand: (c) => this.context.getCommand(c),
|
|
41
|
+
});
|
|
42
|
+
|
|
37
43
|
this.context.setVar('PATH', path);
|
|
38
44
|
this.context.setVar('HOST', hostname);
|
|
39
45
|
if (useRealFilesystem) {
|
|
@@ -223,7 +229,7 @@ class Shell extends EventEmitter {
|
|
|
223
229
|
if(Cmd.prototype instanceof LocalCommand || new Cmd() instanceof ScriptCommand) {
|
|
224
230
|
instance = new Cmd(args, this.context);
|
|
225
231
|
} else if(isCommandClass(Cmd)) {
|
|
226
|
-
instance = new Cmd(args);
|
|
232
|
+
instance = new Cmd(args, this._readonlyContext);
|
|
227
233
|
} else {
|
|
228
234
|
this.emit('stdErr', `${bin}: Command not found`);
|
|
229
235
|
this.lastCode = 1;
|
package/lib/Command.js
CHANGED
|
@@ -6,10 +6,11 @@ const Result = require('./Result');
|
|
|
6
6
|
const EventEmitter = events.EventEmitter || events.default || events;
|
|
7
7
|
|
|
8
8
|
class Command extends EventEmitter {
|
|
9
|
-
constructor(args) {
|
|
9
|
+
constructor(args, context) {
|
|
10
10
|
super();
|
|
11
11
|
this.arguments = args;
|
|
12
12
|
this.result = new Result();
|
|
13
|
+
this.context = context || null;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
get name() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Command = require('./Command');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Base class for interactive full-screen terminal applications (e.g. text editors).
|
|
@@ -19,7 +19,7 @@ const LocalCommand = require('./local/LocalCommand');
|
|
|
19
19
|
*
|
|
20
20
|
* Terminal size is available via `this.terminalSize` → `{ cols, rows }`.
|
|
21
21
|
*/
|
|
22
|
-
class InteractiveCommand extends
|
|
22
|
+
class InteractiveCommand extends Command {
|
|
23
23
|
/**
|
|
24
24
|
* Tells Shell to route all keystrokes here via onInput().
|
|
25
25
|
*/
|