aboutsummaryrefslogtreecommitdiff
path: root/src/js/builtins/ProcessObjectInternals.ts
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-08-10 19:00:06 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-10 19:00:06 -0700
commit513a6d0df3d4d991e76f8e7762df7a07a8087a81 (patch)
treed8f11c4b1a927d6de9cf674c6a8a9a247608def3 /src/js/builtins/ProcessObjectInternals.ts
parent115704b27b85922b32214981b28dfd243e4a7740 (diff)
downloadbun-513a6d0df3d4d991e76f8e7762df7a07a8087a81.tar.gz
bun-513a6d0df3d4d991e76f8e7762df7a07a8087a81.tar.zst
bun-513a6d0df3d4d991e76f8e7762df7a07a8087a81.zip
run files without extensions (#4113)
* run script without extension * process stdio write fix
Diffstat (limited to 'src/js/builtins/ProcessObjectInternals.ts')
-rw-r--r--src/js/builtins/ProcessObjectInternals.ts30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/js/builtins/ProcessObjectInternals.ts b/src/js/builtins/ProcessObjectInternals.ts
index fc6b3800f..af51d25cd 100644
--- a/src/js/builtins/ProcessObjectInternals.ts
+++ b/src/js/builtins/ProcessObjectInternals.ts
@@ -71,6 +71,14 @@ export function getStdioWriteStream(fd_, getWindowSize) {
return fd_;
}
+ get writable() {
+ return this.#writable;
+ }
+
+ get readable() {
+ return this.#readable;
+ }
+
constructor(fd) {
super({ readable: true, writable: true });
this.#fdPath = `/dev/fd/${fd}`;
@@ -120,9 +128,9 @@ export function getStdioWriteStream(fd_, getWindowSize) {
_write(chunk, encoding, callback) {
if (!this.#writeStream) {
var { createWriteStream } = require("node:fs");
- var stream = (this.#writeStream = createWriteStream(this.#fdPath));
+ this.#writeStream = createWriteStream(this.#fdPath);
- stream.on("finish", () => {
+ this.#writeStream.on("finish", () => {
if (this.#onFinish) {
const cb = this.#onFinish;
this.#onFinish = null;
@@ -130,7 +138,7 @@ export function getStdioWriteStream(fd_, getWindowSize) {
}
});
- stream.on("drain", () => {
+ this.#writeStream.on("drain", () => {
if (this.#onDrain) {
const cb = this.#onDrain;
this.#onDrain = null;
@@ -138,15 +146,15 @@ export function getStdioWriteStream(fd_, getWindowSize) {
}
});
- eos(stream, err => {
+ eos(this.#writeStream, err => {
this.#writable = false;
if (err) {
- destroy(stream, err);
+ destroy(this.#writeStream, err);
}
this.#onFinished(err);
});
}
- if (stream.write(chunk, encoding)) {
+ if (this.#writeStream.write(chunk, encoding)) {
callback();
} else {
this.#onDrain = callback;
@@ -296,6 +304,16 @@ export function getStdioWriteStream(fd_, getWindowSize) {
return this.#innerStream._readableState;
}
+ get writable() {
+ this.#ensureInnerStream();
+ return this.#innerStream.writable;
+ }
+
+ get readable() {
+ this.#ensureInnerStream();
+ return this.#innerStream.readable;
+ }
+
pipe(destination) {
this.#ensureInnerStream();
return this.#innerStream.pipe(destination);