Compare commits

...

11 Commits

Author SHA1 Message Date
Caesar2011
6792813ffe Merge pull request #3 from leggenda47/master
Fix script execution.
2020-09-08 15:25:39 +02:00
Petróczi Zoltán
83373b6c7b Fix script execution. 2020-07-07 17:07:48 +02:00
Caesar2011
ff02c8a5a4 Updated URL 2020-06-07 11:49:42 +02:00
Caesar2011
a1f1822c64 Merge pull request #1 from mrothNET/patch-1
Remove double process start on init
2020-05-14 20:34:07 +02:00
Michael Roth
20957dcda8 Merge branch 'master' into patch-1 2020-05-14 19:41:41 +02:00
Caesar2011
9ac5f17b1c Merge pull request #2 from mrothNET/patch-2
Remove unused appInitTime
2020-05-14 17:55:05 +02:00
Michael Roth
2789b6b2e7 Remove unused appInitTime 2020-05-12 00:21:24 +02:00
Michael Roth
6219528dcb Remove double process start on init 2020-05-12 00:00:37 +02:00
Sebastian Seedorf
ce3a42a4d7 Merge branch 'master' of https://github.com/Caesar2011/rhinoder
merge
2020-04-30 19:07:16 +02:00
Sebastian Seedorf
155a02665a Fixed v0.42.0 2020-04-30 18:55:23 +02:00
Caesar2011
0441456068 typo 2020-04-20 18:28:35 +02:00
2 changed files with 6 additions and 10 deletions

View File

@@ -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
View File

@@ -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);
}
}
}