Compare commits
11 Commits
35bc1994dc
...
6792813ffe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6792813ffe | ||
|
|
83373b6c7b | ||
|
|
ff02c8a5a4 | ||
|
|
a1f1822c64 | ||
|
|
20957dcda8 | ||
|
|
9ac5f17b1c | ||
|
|
2789b6b2e7 | ||
|
|
6219528dcb | ||
|
|
ce3a42a4d7 | ||
|
|
155a02665a | ||
|
|
0441456068 |
@@ -4,13 +4,13 @@ This program reloads a deno program automatically when a file in the current wor
|
||||
|
||||
## Usage
|
||||
|
||||
the following code runs `deno --allow-net example.ts` which is located in `/some/work/dir/example.ts` on start an whenever a file in the folder `/some/work/dir` changes.
|
||||
the following code runs `deno --allow-net example.ts` which is located in `/some/work/dir/example.ts` on start and whenever a file in the folder `/some/work/dir` changes.
|
||||
|
||||
|
||||
```bash
|
||||
/some/work/dir$ deno --allow-run --allow-read https://raw.githubusercontent.com/Caesar2011/rhinoder/master/mod.ts --allow-net example.ts
|
||||
/some/work/dir$ deno run --allow-run --allow-read https://deno.land/x/rhinoder@v1.2.0/mod.ts --allow-net example.ts
|
||||
```
|
||||
|
||||
## Thanks to
|
||||
|
||||
Thanks to [samuelgozi](https://github.com/samuelgozi) who posted the base for this code in [this GitHub issue](https://github.com/denoland/deno/issues/4830).
|
||||
Thanks to [samuelgozi](https://github.com/samuelgozi) who posted the base for this code in [this GitHub issue](https://github.com/denoland/deno/issues/4830).
|
||||
|
||||
10
mod.ts
10
mod.ts
@@ -1,23 +1,19 @@
|
||||
function startProcess(args: string[] = []): Deno.Process {
|
||||
return Deno.run({ cmd: ['deno', ...args] });
|
||||
return Deno.run({ cmd: ['deno', 'run', ...args] });
|
||||
}
|
||||
|
||||
const throttle = 500;
|
||||
let app: Deno.Process = startProcess(Deno.args);
|
||||
let appInitTime: number = Date.now();
|
||||
let timeout: number|null = null;
|
||||
|
||||
function runApp() {
|
||||
appInitTime = Date.now();
|
||||
app && app.close();
|
||||
app = startProcess(Deno.args);
|
||||
}
|
||||
|
||||
runApp();
|
||||
|
||||
for await (const event of Deno.fsEvents('.')) {
|
||||
for await (const event of Deno.watchFs('.')) {
|
||||
if (event.kind !== "access") {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
timeout = setTimeout(runApp, throttle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user