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/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 LocalCommand = require('./local/LocalCommand');
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 LocalCommand {
22
+ class InteractiveCommand extends Command {
23
23
  /**
24
24
  * Tells Shell to route all keystrokes here via onInput().
25
25
  */
@@ -4,8 +4,7 @@ const Command = require('../Command');
4
4
 
5
5
  class LocalCommand extends Command {
6
6
  constructor(args, context) {
7
- super(args);
8
- this.context = context;
7
+ super(args, context);
9
8
  }
10
9
  }
11
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brsh",
3
- "version": "2.5.3",
3
+ "version": "2.5.4",
4
4
  "description": "A unix like shell written in javascript",
5
5
  "main": "./dist/shell.min.js",
6
6
  "module": "./dist/shell.es.js",