brsh 3.1.0 → 3.1.2
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 +14 -0
- package/dist/shell.es.js +33 -19
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +2 -2
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +25 -20
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +2 -2
- package/dist/wbt.min.js.map +1 -1
- package/index.js +20 -0
- package/lib/ScriptCommand.js +4 -3
- package/lib/WasmCommand.js +5 -3
- package/lib/wbt/index.js +4 -0
- package/package.json +1 -1
- package/test/shell.test.js +49 -0
- package/test/wbt.test.js +17 -0
package/dist/wbt.es.js
CHANGED
|
@@ -1198,26 +1198,26 @@ var u, d, f, p, m, h, g, _, v, y, b = e((() => {
|
|
|
1198
1198
|
this.sandbox && this.sandbox.onInput(e);
|
|
1199
1199
|
}
|
|
1200
1200
|
run() {
|
|
1201
|
-
let e = this.context.fs.isRealFilesystem ? { useRealFilesystem: !0 } : {
|
|
1202
|
-
filesystem:
|
|
1203
|
-
permissions:
|
|
1201
|
+
let e = this.context && this.context.fs || this.fs, t = e && e.isRealFilesystem ? { useRealFilesystem: !0 } : {
|
|
1202
|
+
filesystem: e && e.getRaw() || {},
|
|
1203
|
+
permissions: e && e.getRawPermissions() || {}
|
|
1204
1204
|
};
|
|
1205
1205
|
this.sandbox = new globalThis.shell({
|
|
1206
|
-
cwd:
|
|
1207
|
-
...
|
|
1206
|
+
cwd: e && e.cwd || "/",
|
|
1207
|
+
...t,
|
|
1208
1208
|
subshell: !0
|
|
1209
1209
|
}), this.sandbox.context.source(this.context), this.sandbox.on("stdOut", (e) => {
|
|
1210
1210
|
this.stdOut = e, this.flush();
|
|
1211
1211
|
}), this.sandbox.on("stdErr", (e) => {
|
|
1212
1212
|
this.stdErr = e, this.flush();
|
|
1213
1213
|
}), this._scriptFunctions = {};
|
|
1214
|
-
let
|
|
1215
|
-
if (!r(
|
|
1216
|
-
let e =
|
|
1214
|
+
let n = this.script.split(/\r?\n/);
|
|
1215
|
+
if (!r(n[0])) {
|
|
1216
|
+
let e = n[0].startsWith("#!") ? n[0].slice(2).split(/\s/)[0] : n[0];
|
|
1217
1217
|
return Promise.reject(`${e}: bad interpreter: No such file or directory`);
|
|
1218
1218
|
}
|
|
1219
|
-
let
|
|
1220
|
-
return this._executeNodes(
|
|
1219
|
+
let i = this._parseLines(n.slice(1));
|
|
1220
|
+
return this._executeNodes(i).catch((e) => {
|
|
1221
1221
|
if (e && e.__type === "return") this.sandbox.lastCode = e.code;
|
|
1222
1222
|
else if (e && e.__type === "errexit") this.sandbox.lastCode = e.code;
|
|
1223
1223
|
else if (e && (e.__type === "break" || e.__type === "continue")) this.stdErr = `${e.__type}: only meaningful in a for or while loop`, this.sandbox.lastCode = 1;
|
|
@@ -2417,21 +2417,23 @@ var R, z, B, V, H, U, W, G, ee, K, te = e((() => {
|
|
|
2417
2417
|
});
|
|
2418
2418
|
}
|
|
2419
2419
|
_loadBytes(e, t) {
|
|
2420
|
-
|
|
2421
|
-
|
|
2420
|
+
let n = this.context && this.context.fs || this.fs;
|
|
2421
|
+
if (!n) return Promise.reject(/* @__PURE__ */ Error(`${e}: Filesystem is not available`));
|
|
2422
|
+
if (n.isRealFilesystem && t) try {
|
|
2423
|
+
let r = t.readFileSync(n.absolutePath(e)), i = new Uint8Array(r);
|
|
2422
2424
|
return Promise.resolve({
|
|
2423
|
-
bytes:
|
|
2424
|
-
isWat: this._isWat(e,
|
|
2425
|
+
bytes: i,
|
|
2426
|
+
isWat: this._isWat(e, i)
|
|
2425
2427
|
});
|
|
2426
2428
|
} catch (t) {
|
|
2427
2429
|
return Promise.reject(/* @__PURE__ */ Error(`${e}: ${t.message}`));
|
|
2428
2430
|
}
|
|
2429
|
-
let
|
|
2430
|
-
if (
|
|
2431
|
-
let
|
|
2431
|
+
let r = n.getFileByPath(e);
|
|
2432
|
+
if (r == null) return Promise.reject(/* @__PURE__ */ Error(`${e}: No such file or directory`));
|
|
2433
|
+
let i = this._contentToBytes(r);
|
|
2432
2434
|
return Promise.resolve({
|
|
2433
|
-
bytes:
|
|
2434
|
-
isWat: this._isWat(e,
|
|
2435
|
+
bytes: i,
|
|
2436
|
+
isWat: this._isWat(e, i)
|
|
2435
2437
|
});
|
|
2436
2438
|
}
|
|
2437
2439
|
_isWat(e, t) {
|
|
@@ -4462,8 +4464,11 @@ var R, z, B, V, H, U, W, G, ee, K, te = e((() => {
|
|
|
4462
4464
|
get name() {
|
|
4463
4465
|
return e;
|
|
4464
4466
|
}
|
|
4467
|
+
get requiresFilesystem() {
|
|
4468
|
+
return !0;
|
|
4469
|
+
}
|
|
4465
4470
|
constructor(e, r) {
|
|
4466
|
-
super(t, e, r), this.script = t, this.arguments = e || [], this.context = r || null, this._pkgMeta = n;
|
|
4471
|
+
super(t, e, r), this.script = t, this.arguments = e || [], this.context = r || null, r && r.fs && !this.fs && (this.fs = r.fs), this._pkgMeta = n;
|
|
4467
4472
|
}
|
|
4468
4473
|
}
|
|
4469
4474
|
return r;
|