brsh 1.4.0 → 2.0.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.
Files changed (57) hide show
  1. package/.github/workflows/busybox-compat.yml +166 -0
  2. package/.github/workflows/release.yml +40 -0
  3. package/.releaserc.json +18 -0
  4. package/CHANGELOG.md +355 -0
  5. package/bin/brsh-cmd.js +78 -0
  6. package/bin/exportFileSystem.js +81 -156
  7. package/busybox-testsuite/cat.tests +49 -0
  8. package/busybox-testsuite/cp.tests +206 -0
  9. package/busybox-testsuite/grep.tests +237 -0
  10. package/busybox-testsuite/testing.sh +180 -0
  11. package/dist/brsh.css +2 -0
  12. package/dist/shell.es.js +5667 -0
  13. package/dist/shell.es.js.map +1 -0
  14. package/dist/shell.min.js +14 -222
  15. package/dist/shell.min.js.map +1 -149
  16. package/dist/terminal.es.js +6228 -0
  17. package/dist/terminal.es.js.map +1 -0
  18. package/dist/terminal.min.js +113 -18
  19. package/dist/terminal.min.js.map +1 -21
  20. package/index.js +206 -49
  21. package/lib/Context.js +12 -4
  22. package/lib/FileSystem.js +99 -6
  23. package/lib/NodeFileSystem.js +238 -0
  24. package/lib/ScriptCommand.js +193 -15
  25. package/lib/Terminal.js +188 -12
  26. package/lib/WasmCommand.js +252 -0
  27. package/lib/buildFilesystemStructure.js +58 -0
  28. package/lib/builtins/cat.js +67 -9
  29. package/lib/builtins/echo.js +36 -5
  30. package/lib/builtins/false.js +13 -0
  31. package/lib/builtins/grep.js +267 -0
  32. package/lib/builtins/index.js +9 -2
  33. package/lib/builtins/ls.js +86 -18
  34. package/lib/builtins/test.js +105 -0
  35. package/lib/builtins/true.js +10 -0
  36. package/lib/local/chmod.js +72 -0
  37. package/lib/local/cp.js +156 -0
  38. package/lib/local/index.js +8 -1
  39. package/lib/local/jsfunction.js +58 -0
  40. package/lib/local/mkdir.js +44 -0
  41. package/lib/local/mv.js +96 -0
  42. package/lib/local/pwd.js +13 -0
  43. package/lib/local/read.js +6 -4
  44. package/lib/local/rm.js +71 -0
  45. package/lib/local/which.js +2 -2
  46. package/package.json +31 -34
  47. package/test/builtins.test.js +505 -0
  48. package/test/exportFileSystem.test.js +226 -0
  49. package/test/helpers.js +35 -0
  50. package/test/local-commands.test.js +593 -0
  51. package/test/node-filesystem.test.js +133 -0
  52. package/test/scripts.test.js +277 -0
  53. package/test/shell.test.js +245 -0
  54. package/test/streaming.test.js +113 -0
  55. package/vite.config.shell.js +21 -0
  56. package/vite.config.terminal.js +27 -0
  57. package/vitest.config.js +15 -0
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+
5
+ class Chmod extends LocalCommand {
6
+ get name() { return 'chmod'; }
7
+ get requiresFilesystem() { return true; }
8
+
9
+ run() {
10
+ const args = this.arguments;
11
+ if (args.length < 2) {
12
+ this.stdErr = 'chmod: usage: chmod MODE FILE...';
13
+ this.exitCode = 1;
14
+ return Promise.resolve();
15
+ }
16
+
17
+ const modeStr = args[0];
18
+ const paths = args.slice(1);
19
+
20
+ for (const p of paths) {
21
+ const file = this.fs.getFileByPath(p);
22
+ if (file === null || file === undefined) {
23
+ this.stdErr = `chmod: cannot access '${p}': No such file or directory`;
24
+ this.exitCode = 1;
25
+ continue;
26
+ }
27
+
28
+ const currentMode = this.fs.getMode(p);
29
+ const mode = this._parseMode(modeStr, currentMode !== null ? currentMode : 0o644);
30
+ if (mode === null) {
31
+ this.stdErr = `chmod: invalid mode: '${modeStr}'`;
32
+ this.exitCode = 1;
33
+ return Promise.resolve();
34
+ }
35
+ this.fs.setMode(p, mode);
36
+ }
37
+ return Promise.resolve();
38
+ }
39
+
40
+ _parseMode(str, current) {
41
+ if (/^0?[0-7]{3,4}$/.test(str)) {
42
+ return parseInt(str, 8);
43
+ }
44
+ const match = str.match(/^([ugoa]*)([+\-=])([rwx]+)$/);
45
+ if (!match) return null;
46
+
47
+ const [, who, op, perms] = match;
48
+ const targets = (!who || who === 'a') ? ['u', 'g', 'o'] : who.split('');
49
+
50
+ const R = { u: 0o400, g: 0o040, o: 0o004 };
51
+ const W = { u: 0o200, g: 0o020, o: 0o002 };
52
+ const X = { u: 0o100, g: 0o010, o: 0o001 };
53
+
54
+ let mask = 0;
55
+ for (const t of targets) {
56
+ if (perms.includes('r')) mask |= R[t];
57
+ if (perms.includes('w')) mask |= W[t];
58
+ if (perms.includes('x')) mask |= X[t];
59
+ }
60
+
61
+ if (op === '+') return current | mask;
62
+ if (op === '-') return current & ~mask;
63
+ if (op === '=') {
64
+ let clear = 0;
65
+ for (const t of targets) { clear |= R[t] | W[t] | X[t]; }
66
+ return (current & ~clear) | mask;
67
+ }
68
+ return null;
69
+ }
70
+ }
71
+
72
+ module.exports = Chmod;
@@ -0,0 +1,156 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+ const nodeFs = require('fs');
5
+
6
+ class Cp extends LocalCommand {
7
+ get name() { return 'cp'; }
8
+ get requiresFilesystem() { return true; }
9
+
10
+ run() {
11
+ let recursive = false;
12
+ // symlinkMode: 'follow' | 'preserve' | 'follow_cl'
13
+ // 'follow' - dereference all symlinks
14
+ // 'preserve' - keep symlinks as symlinks (default with -R)
15
+ // 'follow_cl' - follow command-line symlinks, preserve during recursion (-H)
16
+ let symlinkMode = null; // null = unset; resolved after parsing
17
+ let rSeen = false;
18
+ let hSeen = false;
19
+ let childSymlinkModeOverride = null; // tracks last -L/-P/-d for child mode when -H is last
20
+ const paths = [];
21
+
22
+ const args = [...this.arguments];
23
+ let i = 0;
24
+ while (i < args.length) {
25
+ const arg = args[i];
26
+ if (arg === '--') { i++; break; }
27
+ if (arg.startsWith('-') && arg.length > 1) {
28
+ for (const ch of arg.slice(1)) {
29
+ switch (ch) {
30
+ case 'r': case 'R': recursive = true; rSeen = true; break;
31
+ case 'a': recursive = true; rSeen = true; symlinkMode = 'preserve'; childSymlinkModeOverride = 'preserve'; break;
32
+ case 'd': case 'P': symlinkMode = 'preserve'; childSymlinkModeOverride = 'preserve'; break;
33
+ case 'L': symlinkMode = 'follow'; childSymlinkModeOverride = 'follow'; break;
34
+ case 'H': symlinkMode = 'follow_cl'; hSeen = true; break;
35
+ case 'f': break;
36
+ }
37
+ }
38
+ } else {
39
+ paths.push(arg);
40
+ }
41
+ i++;
42
+ }
43
+ while (i < args.length) paths.push(args[i++]);
44
+
45
+ // Resolve default symlink mode: -R without explicit flag → preserve
46
+ const resolvedMode = symlinkMode !== null ? symlinkMode
47
+ : rSeen ? 'preserve'
48
+ : 'follow';
49
+
50
+ if (paths.length < 2) {
51
+ this.stdErr = `cp: missing destination file operand${paths.length ? ` after '${paths[0]}'` : ''}`;
52
+ this.exitCode = 1;
53
+ return Promise.resolve();
54
+ }
55
+
56
+ const dest = paths[paths.length - 1];
57
+ const sources = paths.slice(0, -1);
58
+ const destEntry = this.fs.getFileByPath(dest);
59
+ const destIsDir = destEntry !== null && destEntry !== undefined && destEntry.constructor === Object;
60
+
61
+ // Determine per-item copy mode and the mode for recursive children.
62
+ // -H always takes effect for CL-level symlinks (follow), regardless of which mode wins.
63
+ // Child mode comes from the overriding -L/-P flag, or 'preserve' if H alone.
64
+ // When H is not present, both levels use resolvedMode.
65
+ const clItemMode = hSeen ? 'follow' : (resolvedMode === 'follow_cl' ? 'follow' : resolvedMode);
66
+ const childMode = (hSeen || resolvedMode === 'follow_cl')
67
+ ? (childSymlinkModeOverride !== null ? childSymlinkModeOverride : 'preserve')
68
+ : resolvedMode;
69
+
70
+ for (const src of sources) {
71
+ const isLink = this.fs.isSymlink ? this.fs.isSymlink(src) : false;
72
+
73
+ // Stat (follows symlinks) to get effective type
74
+ const stat = this.fs.getFileByPath(src);
75
+ if (stat === null || stat === undefined) {
76
+ this.stdErr = `cp: cannot stat '${src}': No such file or directory`;
77
+ this.exitCode = 1;
78
+ continue;
79
+ }
80
+
81
+ // If we're preserving this symlink, it won't become a directory
82
+ const effectiveIsDir = (isLink && clItemMode === 'preserve')
83
+ ? false
84
+ : stat.constructor === Object;
85
+
86
+ if (effectiveIsDir && !recursive) {
87
+ this.stdErr = `cp: omitting directory '${src}'`;
88
+ this.exitCode = 1;
89
+ continue;
90
+ }
91
+
92
+ const targetPath = destIsDir
93
+ ? dest.replace(/\/$/, '') + '/' + src.split('/').pop()
94
+ : dest;
95
+
96
+ const err = this._copy(src, targetPath, clItemMode, isLink, childMode);
97
+ if (err) {
98
+ this.stdErr = err;
99
+ this.exitCode = 1;
100
+ }
101
+ }
102
+ return Promise.resolve();
103
+ }
104
+
105
+ // mode: how to handle symlinks for this item ('follow' | 'preserve')
106
+ // childMode: how to handle symlinks for recursive children
107
+ _copy(src, dest, mode, isLink, childMode) {
108
+ if (isLink && mode === 'preserve' && this.fs.readSymlink) {
109
+ const target = this.fs.readSymlink(src);
110
+ if (target === null) return `cp: cannot read symlink '${src}'`;
111
+ try {
112
+ this.fs.createSymlink(target, dest);
113
+ } catch(e) {
114
+ return `cp: cannot create symlink '${dest}': ${e.message}`;
115
+ }
116
+ return null;
117
+ }
118
+
119
+ const content = this.fs.getFileByPath(src);
120
+ if (content === null || content === undefined) {
121
+ return `cp: cannot stat '${src}': No such file or directory`;
122
+ }
123
+
124
+ if (content.constructor === Object) {
125
+ try {
126
+ this.fs.setFileByPath(dest, {}, true);
127
+ } catch(e) {
128
+ return `cp: cannot create directory '${dest}': ${e.message}`;
129
+ }
130
+
131
+ const absDir = this.fs.absolutePath(src);
132
+ let entries;
133
+ try {
134
+ entries = nodeFs.readdirSync(absDir);
135
+ } catch(e) {
136
+ entries = Object.keys(content);
137
+ }
138
+
139
+ for (const name of entries) {
140
+ const childSrc = src.replace(/\/$/, '') + '/' + name;
141
+ const childDest = dest.replace(/\/$/, '') + '/' + name;
142
+ const childIsLink = this.fs.isSymlink ? this.fs.isSymlink(childSrc) : false;
143
+ const err = this._copy(childSrc, childDest, childMode, childIsLink, childMode);
144
+ if (err) {
145
+ this.stdErr = err;
146
+ this.exitCode = 1;
147
+ }
148
+ }
149
+ } else {
150
+ this.fs.setFileByPath(dest, content, true);
151
+ }
152
+ return null;
153
+ }
154
+ }
155
+
156
+ module.exports = Cp;
@@ -4,10 +4,17 @@ module.exports = [
4
4
  require('./alias'),
5
5
  require('./export'),
6
6
  require('./cd'),
7
+ require('./chmod'),
8
+ require('./cp'),
9
+ require('./mkdir'),
10
+ require('./mv'),
11
+ require('./pwd'),
12
+ require('./rm'),
7
13
  require('./which'),
8
14
  require('./source'),
9
15
  require('./clear'),
10
16
  require('./exit'),
11
- require('./read')
17
+ require('./read'),
18
+ require('./jsfunction')
12
19
  ];
13
20
 
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+ const Command = require('../Command');
5
+
6
+ class JsFunction extends LocalCommand {
7
+ get name() { return 'jsfunction'; }
8
+
9
+ run() {
10
+ const [name, ...bodyParts] = this.arguments;
11
+ if (!name || bodyParts.length === 0) {
12
+ this.stdErr = 'usage: jsfunction <name> <function-body>';
13
+ this.exitCode = 1;
14
+ return Promise.resolve();
15
+ }
16
+
17
+ const body = bodyParts.join(' ');
18
+ let fn;
19
+ try {
20
+ // eslint-disable-next-line no-new-func
21
+ fn = new Function('return (' + body + ')')();
22
+ if (typeof fn !== 'function') throw new Error('expression is not a function');
23
+ } catch(e) {
24
+ this.stdErr = `jsfunction: ${e.message}`;
25
+ this.exitCode = 1;
26
+ return Promise.resolve();
27
+ }
28
+
29
+ class DynamicCommand extends Command {
30
+ run() {
31
+ let result;
32
+ try {
33
+ result = fn(this.arguments);
34
+ } catch(e) {
35
+ this.stdErr = e.message || String(e);
36
+ this.exitCode = 1;
37
+ return Promise.resolve();
38
+ }
39
+ if (result && typeof result.then === 'function') {
40
+ return result.then(v => {
41
+ if (v != null) this.stdOut = String(v);
42
+ }).catch(e => {
43
+ this.stdErr = e.message || String(e);
44
+ this.exitCode = 1;
45
+ });
46
+ }
47
+ if (result != null) this.stdOut = String(result);
48
+ return Promise.resolve();
49
+ }
50
+ }
51
+ Object.defineProperty(DynamicCommand, 'name', { value: name, configurable: true });
52
+
53
+ this.context.setCommand(DynamicCommand);
54
+ return Promise.resolve();
55
+ }
56
+ }
57
+
58
+ module.exports = JsFunction;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+
5
+ class Mkdir extends LocalCommand {
6
+ get name() { return 'mkdir'; }
7
+ get requiresFilesystem() { return true; }
8
+
9
+ run() {
10
+ let createParents = false;
11
+ const paths = [];
12
+
13
+ for (const arg of this.arguments) {
14
+ if (arg === '-p' || arg === '--parents') createParents = true;
15
+ else paths.push(arg);
16
+ }
17
+
18
+ if (paths.length === 0) {
19
+ this.stdErr = 'mkdir: missing operand';
20
+ this.exitCode = 1;
21
+ return Promise.resolve();
22
+ }
23
+
24
+ for (const dir of paths) {
25
+ const existing = this.fs.getFileByPath(dir);
26
+ if (existing !== null && existing !== undefined) {
27
+ if (!createParents) {
28
+ this.stdErr = `mkdir: cannot create directory '${dir}': File exists`;
29
+ this.exitCode = 1;
30
+ }
31
+ continue;
32
+ }
33
+ try {
34
+ this.fs.setFileByPath(dir, {}, createParents);
35
+ } catch(e) {
36
+ this.stdErr = `mkdir: cannot create directory '${dir}': ${e.message}`;
37
+ this.exitCode = 1;
38
+ }
39
+ }
40
+ return Promise.resolve();
41
+ }
42
+ }
43
+
44
+ module.exports = Mkdir;
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+ const nodeFs = require('fs');
5
+
6
+ class Mv extends LocalCommand {
7
+ get name() { return 'mv'; }
8
+ get requiresFilesystem() { return true; }
9
+
10
+ run() {
11
+ let destFirst = null;
12
+ const rawPaths = [];
13
+
14
+ const args = [...this.arguments];
15
+ let i = 0;
16
+ while (i < args.length) {
17
+ const arg = args[i];
18
+ if (arg === '--') { i++; break; }
19
+ if (arg.startsWith('-') && arg.length > 1) {
20
+ for (let j = 1; j < arg.length; j++) {
21
+ switch (arg[j]) {
22
+ case 'f': case 'i': case 'n': break;
23
+ case 't': {
24
+ const rest = arg.slice(j + 1);
25
+ destFirst = rest.length > 0 ? rest : args[++i];
26
+ j = arg.length;
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ } else {
32
+ rawPaths.push(arg);
33
+ }
34
+ i++;
35
+ }
36
+ while (i < args.length) rawPaths.push(args[i++]);
37
+
38
+ const dest = destFirst !== null ? destFirst : rawPaths[rawPaths.length - 1];
39
+ const sources = destFirst !== null ? rawPaths : rawPaths.slice(0, -1);
40
+
41
+ if (!dest || sources.length === 0) {
42
+ this.stdErr = `mv: missing destination file operand${sources.length ? ` after '${sources[0]}'` : ''}`;
43
+ this.exitCode = 1;
44
+ return Promise.resolve();
45
+ }
46
+
47
+ const destEntry = this.fs.getFileByPath(dest);
48
+ const destIsDir = destEntry !== null && destEntry !== undefined && destEntry.constructor === Object;
49
+
50
+ for (const src of sources) {
51
+ const targetPath = destIsDir
52
+ ? dest.replace(/\/$/, '') + '/' + src.split('/').pop()
53
+ : dest;
54
+
55
+ if (this.fs.isRealFilesystem) {
56
+ const srcAbs = this.fs.absolutePath(src);
57
+ const destAbs = this.fs.absolutePath(targetPath);
58
+ // lstatSync works for unreadable files and dangling symlinks;
59
+ // getFileByPath would return null for both, masking existence.
60
+ try { nodeFs.lstatSync(srcAbs); } catch {
61
+ this.stdErr = `mv: cannot stat '${src}': No such file or directory`;
62
+ this.exitCode = 1;
63
+ continue;
64
+ }
65
+ try {
66
+ const nodePath = require('path');
67
+ nodeFs.mkdirSync(nodePath.dirname(destAbs), { recursive: true });
68
+ nodeFs.renameSync(srcAbs, destAbs);
69
+ } catch(e) {
70
+ this.stdErr = `mv: cannot move '${src}' to '${targetPath}': ${e.message}`;
71
+ this.exitCode = 1;
72
+ }
73
+ } else {
74
+ const srcEntry = this.fs.getFileByPath(src);
75
+ if (srcEntry === null || srcEntry === undefined) {
76
+ this.stdErr = `mv: cannot stat '${src}': No such file or directory`;
77
+ this.exitCode = 1;
78
+ continue;
79
+ }
80
+ this.fs.setFileByPath(targetPath, this._deepCopy(srcEntry), true);
81
+ this.fs.deleteFileByPath(src);
82
+ }
83
+ }
84
+ return Promise.resolve();
85
+ }
86
+
87
+ _deepCopy(content) {
88
+ if (content === null || content === undefined) return content;
89
+ if (typeof content === 'function' || typeof content !== 'object') return content;
90
+ const copy = {};
91
+ for (const [k, v] of Object.entries(content)) copy[k] = this._deepCopy(v);
92
+ return copy;
93
+ }
94
+ }
95
+
96
+ module.exports = Mv;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+
5
+ class Pwd extends LocalCommand {
6
+ run() {
7
+ const cwd = this.context.fs.cwd;
8
+ this.stdOut = cwd.endsWith('/') && cwd !== '/' ? cwd.slice(0, -1) : cwd;
9
+ return Promise.resolve();
10
+ }
11
+ }
12
+
13
+ module.exports = Pwd;
package/lib/local/read.js CHANGED
@@ -29,9 +29,6 @@ class Read extends LocalCommand {
29
29
  this.nchars = options.nchars;
30
30
  this.var = options.name;
31
31
 
32
- this.stdErr = options.prompt || "";
33
- this.flush();
34
-
35
32
  return new Promise((resolve) => {
36
33
  const tid = setTimeout(() => {
37
34
  resolve();
@@ -41,7 +38,12 @@ class Read extends LocalCommand {
41
38
  this.completionCallback = (data) => {
42
39
  clearTimeout(tid);
43
40
  resolve(data);
44
- }
41
+ };
42
+
43
+ // Flush prompt after completionCallback is set so that any
44
+ // synchronous onInput triggered by the prompt can complete it.
45
+ this.stdErr = options.prompt || "";
46
+ this.flush();
45
47
  });
46
48
  }
47
49
 
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ const LocalCommand = require('./LocalCommand');
4
+ const nodeFs = require('fs');
5
+
6
+ class Rm extends LocalCommand {
7
+ get name() { return 'rm'; }
8
+ get requiresFilesystem() { return true; }
9
+
10
+ run() {
11
+ let recursive = false;
12
+ let force = false;
13
+ const paths = [];
14
+
15
+ for (const arg of this.arguments) {
16
+ if (/^-[rRf]+$/.test(arg)) {
17
+ if (arg.includes('r') || arg.includes('R')) recursive = true;
18
+ if (arg.includes('f')) force = true;
19
+ } else {
20
+ paths.push(arg);
21
+ }
22
+ }
23
+
24
+ if (paths.length === 0) {
25
+ if (!force) {
26
+ this.stdErr = 'rm: missing operand';
27
+ this.exitCode = 1;
28
+ }
29
+ return Promise.resolve();
30
+ }
31
+
32
+ for (const path of paths) {
33
+ try {
34
+ this._remove(path, recursive, force);
35
+ } catch(e) {
36
+ this.stdErr = e.message;
37
+ this.exitCode = 1;
38
+ }
39
+ }
40
+ return Promise.resolve();
41
+ }
42
+
43
+ _remove(path, recursive, force) {
44
+ const isLink = this.fs.isSymlink ? this.fs.isSymlink(path) : false;
45
+ if (!isLink) {
46
+ const file = this.fs.getFileByPath(path);
47
+ if (file === null || file === undefined) {
48
+ if (!force) throw new Error(`rm: cannot remove '${path}': No such file or directory`);
49
+ return;
50
+ }
51
+ if (file.constructor === Object) {
52
+ if (!recursive) throw new Error(`rm: cannot remove '${path}': Is a directory`);
53
+ // Use readdirSync on real fs to catch all entries including dangling symlinks,
54
+ // which getFileByPath skips because statSync throws for them.
55
+ let children;
56
+ if (this.fs.isRealFilesystem) {
57
+ try { children = nodeFs.readdirSync(this.fs.absolutePath(path)); } catch(e) { children = []; }
58
+ } else {
59
+ children = Object.keys(file);
60
+ }
61
+ for (const key of children) {
62
+ const childPath = path.replace(/\/$/, '') + '/' + key;
63
+ this._remove(childPath, recursive, force);
64
+ }
65
+ }
66
+ }
67
+ this.fs.deleteFileByPath(path);
68
+ }
69
+ }
70
+
71
+ module.exports = Rm;
@@ -8,13 +8,13 @@ class Which extends LocalCommand {
8
8
  return Promise.reject('which requires a single argument');
9
9
  }
10
10
 
11
- const file = this.context.fs.getFileByPath(`${this.context.getVar('PATH')}/${this.arguments[0]}}`);
11
+ const file = this.context.fs.getFileByPath(`${this.context.getVar('PATH')}/${this.arguments[0]}`);
12
12
 
13
13
  if(!file || file.constructor === Object || file.constructor === String) {
14
14
  return Promise.reject();
15
15
  }
16
16
 
17
- return Promise.resolve(path);
17
+ return Promise.resolve(`${this.context.getVar('PATH')}/${this.arguments[0]}`);
18
18
  }
19
19
  }
20
20
 
package/package.json CHANGED
@@ -1,20 +1,31 @@
1
1
  {
2
2
  "name": "brsh",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "A unix like shell written in javascript",
5
- "main": "index.js",
6
- "browser": {
7
- "Shell": "./index.js"
5
+ "main": "./dist/shell.min.js",
6
+ "module": "./dist/shell.es.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/shell.es.js",
10
+ "require": "./dist/shell.min.js",
11
+ "default": "./dist/shell.min.js"
12
+ },
13
+ "./terminal": {
14
+ "import": "./dist/terminal.es.js",
15
+ "require": "./dist/terminal.min.js",
16
+ "default": "./dist/terminal.min.js"
17
+ }
8
18
  },
9
19
  "bin": {
10
20
  "exportFileSystem": "bin/exportFileSystem.js"
11
21
  },
12
22
  "scripts": {
13
- "start": "budo ./demo/demo.js",
23
+ "start": "vite demo/",
14
24
  "build": "npm run build:shell && npm run build:terminal",
15
- "build:shell": "browserify ./index.js --standalone Shell -d -p bundle-collapser/plugin -p common-shakeify -g uglifyify | exorcist dist/shell.min.js.map > dist/shell.min.js",
16
- "build:terminal": "browserify ./lib/terminal -x Shell -t browserify-shim --standalone Terminal -d -p bundle-collapser/plugin -p common-shakeify -g uglifyify | exorcist dist/terminal.min.js.map > dist/terminal.min.js",
17
- "test": "echo \"Error: no test specified\" && exit 1",
25
+ "build:shell": "vite build --config vite.config.shell.js",
26
+ "build:terminal": "vite build --config vite.config.terminal.js",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest",
18
29
  "prepublishOnly": "npm run build"
19
30
  },
20
31
  "repository": {
@@ -24,35 +35,21 @@
24
35
  "author": "Eliot Stocker",
25
36
  "license": "GPL-3.0",
26
37
  "devDependencies": {
27
- "brfs": "^2.0.2",
28
- "browserify": "^16.5.0",
29
- "browserify-css": "^0.15.0",
30
- "browserify-shim": "^3.8.14",
31
- "budo": "^11.6.3",
32
- "bundle-collapser": "^1.3.0",
33
- "common-shakeify": "^0.6.2",
34
- "exorcist": "^1.0.1",
35
- "readline": "^1.3.0",
36
- "url-loader": "^4.1.1",
37
- "uglifyify": "^5.0.2"
38
+ "@semantic-release/changelog": "^6.0.3",
39
+ "@semantic-release/git": "^10.0.1",
40
+ "@vitest/coverage-v8": "^4.1.5",
41
+ "esbuild": "^0.25.9",
42
+ "semantic-release": "^25.0.3",
43
+ "vite": "^8.0.10",
44
+ "vite-plugin-node-polyfills": "^0.26.0",
45
+ "vitest": "^4.1.5"
38
46
  },
39
47
  "dependencies": {
40
48
  "ansi_up": "git+https://github.com/eliotstocker/ansi_up.git",
41
- "command-line-args": "^5.1.1",
42
- "node-polyfill-webpack-plugin": "^1.1.4",
43
- "string.prototype.matchall": "^3.0.1",
49
+ "command-line-args": "^6.0.1",
50
+ "esbuild-plugin-polyfill-node": "^0.3.0",
51
+ "string.prototype.matchall": "^4.0.12",
44
52
  "through2": "^4.0.2",
45
- "tmp": "^0.1.0",
46
- "webpack": "^5.49.0",
47
- "webpack-stream": "^6.1.2"
48
- },
49
- "browserify": {
50
- "transform": [
51
- "brfs",
52
- "browserify-css"
53
- ]
54
- },
55
- "browserify-shim": {
56
- "Shell": "global:Shell"
53
+ "tmp": "^0.2.5"
57
54
  }
58
55
  }