Skip to content

Commit 44a662a

Browse files
committed
remove bun fs.watch workaround
1 parent a78451e commit 44a662a

2 files changed

Lines changed: 7 additions & 28 deletions

File tree

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rtjscomp",
3-
"version": "0.9.17",
3+
"version": "0.9.18",
44
"description": "php-like server but with javascript",
55
"repository": {
66
"type": "git",
@@ -13,7 +13,9 @@
1313
"start": "./rtjscomp.js",
1414
"build": "./build.js"
1515
},
16-
"bin": "./rtjscomp.js",
16+
"bin": {
17+
"rtjscomp": "./rtjscomp.js"
18+
},
1719
"keywords": [
1820
"http",
1921
"javascript",

rtjscomp.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,6 @@ if (!Object.fromEntries) {
131131
}
132132
}
133133

134-
// workaround for bun: https://github.com/oven-sh/bun/issues/18919
135-
let fs_watch = fs.watch;
136-
if (IS_BUN) {
137-
const fs_watch_original = fs_watch;
138-
const watch_callbacks = new Map;
139-
fs_watch = (path, options, callback) => {
140-
if (!watch_callbacks.has(path)) {
141-
fs_watch_original(path, options, () => {
142-
const callback = watch_callbacks.get(path);
143-
if (callback) {
144-
callback();
145-
}
146-
});
147-
}
148-
watch_callbacks.set(path, callback);
149-
return {
150-
close: () => (
151-
watch_callbacks.set(path, null)
152-
),
153-
};
154-
}
155-
}
156-
157134
// legacy, will be removed soon!
158135
global.globals = rtjscomp;
159136
global.actions = rtjscomp.actions;
@@ -378,7 +355,7 @@ const service_update = async service_object => {
378355
if (service_object.status !== SERVICE_STATUS_PENDING) return;
379356
if (!service_object.watcher) {
380357
let timeout = 0;
381-
service_object.watcher = fs_watch(path_real, WATCH_OPTIONS, () => (
358+
service_object.watcher = fs.watch(path_real, WATCH_OPTIONS, () => (
382359
clearTimeout(timeout),
383360
timeout = setTimeout(() => (
384361
log_verbose && log('file updated: ' + path),
@@ -613,7 +590,7 @@ const service_require_try = path => {
613590
}
614591

615592
const file_watch_once = (path, callback) => {
616-
const watcher = fs_watch(path, WATCH_OPTIONS, () => (
593+
const watcher = fs.watch(path, WATCH_OPTIONS, () => (
617594
watcher.close(),
618595
log_verbose && log('file updated: ' + path),
619596
callback()
@@ -631,7 +608,7 @@ const file_keep_new = async (path, callback) => {
631608
}
632609

633610
let timeout = 0;
634-
return fs_watch(path, WATCH_OPTIONS, () => (
611+
return fs.watch(path, WATCH_OPTIONS, () => (
635612
clearTimeout(timeout),
636613
timeout = setTimeout(() => exiting || (
637614
log_verbose && log('file updated: ' + path),

0 commit comments

Comments
 (0)