Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
azizghuloum committed Dec 26, 2024
1 parent 8798cb3 commit 2fd4234
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
32 changes: 10 additions & 22 deletions rtsc/compile-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ class DirWatcher {
const filename = basename(path);
assert(!this.callbacks[filename], `multiple watches for same path '${path}'`);
this.callbacks[filename] = callback;
return {
close() {
throw new Error(`close is not yet done`);
},
const close = () => {
assert(this.callbacks[filename] !== undefined, `no callback registered`);
assert(this.callbacks[filename] === callback, `closing wrong watch`);
delete this.callbacks[filename];
};
return { close };
}
processEvent(event: "rename" | "change", file: string) {
processEvent(file: string) {
this.onEvent?.(file);
const callback = this.callbacks[file];
if (callback) callback(join(this.dir, file));
Expand All @@ -52,12 +53,12 @@ class WatchFS {
private get_or_create_watcher(abspath: string): DirWatcher {
const existing = this.dir_watchers[abspath];
if (existing) return existing;
const fswatcher = watch(abspath, { encoding: "utf8", recursive: false }, (event, file) => {
assert(file !== null);
watcher.processEvent(event, file);
});
const watcher = new DirWatcher(abspath);
this.dir_watchers[abspath] = watcher;
watch(abspath, { encoding: "utf8", recursive: false }, (_event, file) => {
assert(file !== null);
watcher.processEvent(file);
});
return watcher;
}

Expand Down Expand Up @@ -118,19 +119,6 @@ function check_path(rts_file: string) {
library_manager
.findPackage(rts_file)
.then(([pkg, rel]) => library_manager.ensureUpToDate(pkg, rel, rts_file));
//const suffix = ".rts";
//if (path.endsWith(suffix)) {
// const module_dir = dirname(path);
// const module_name = basename(path, suffix) + ".rts";
// const rts_file = join(module_dir, module_name);
// fs.stat(rts_file).then((stats) => {
// library_manager.ensureUpToDate(rts_file);
// });
//}
}

const FS = new WatchFS(check_path);

//console.log(path.relative("/x/a/b/c", "/x/a/b2/c2"));

//const watcher = watch(".", {}, (event, filename) => console.log({ event, filename }));
1 change: 0 additions & 1 deletion src/parse-dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ function parse_statements(statements: TS.NodeArray<TS.Statement>, path: string):
}

export function parse_dts(code: string, my_path: string, full_path: string): ts_exports {
console.log(`parsing ${full_path}`);
const options: TS.CreateSourceFileOptions = {
languageVersion: TS.ScriptTarget.ESNext,
jsDocParsingMode: TS.JSDocParsingMode.ParseNone,
Expand Down

0 comments on commit 2fd4234

Please sign in to comment.