Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6792813ffe | ||
|
|
83373b6c7b | ||
|
|
ff02c8a5a4 | ||
|
|
a1f1822c64 | ||
|
|
20957dcda8 | ||
|
|
9ac5f17b1c | ||
|
|
2789b6b2e7 | ||
|
|
6219528dcb | ||
|
|
ce3a42a4d7 | ||
|
|
155a02665a | ||
|
|
0441456068 |
@@ -4,11 +4,11 @@ This program reloads a deno program automatically when a file in the current wor
|
|||||||
|
|
||||||
## Usage
|
## 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
|
```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
|
||||||
|
|||||||
8
mod.ts
8
mod.ts
@@ -1,21 +1,17 @@
|
|||||||
function startProcess(args: string[] = []): Deno.Process {
|
function startProcess(args: string[] = []): Deno.Process {
|
||||||
return Deno.run({ cmd: ['deno', ...args] });
|
return Deno.run({ cmd: ['deno', 'run', ...args] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const throttle = 500;
|
const throttle = 500;
|
||||||
let app: Deno.Process = startProcess(Deno.args);
|
let app: Deno.Process = startProcess(Deno.args);
|
||||||
let appInitTime: number = Date.now();
|
|
||||||
let timeout: number|null = null;
|
let timeout: number|null = null;
|
||||||
|
|
||||||
function runApp() {
|
function runApp() {
|
||||||
appInitTime = Date.now();
|
|
||||||
app && app.close();
|
app && app.close();
|
||||||
app = startProcess(Deno.args);
|
app = startProcess(Deno.args);
|
||||||
}
|
}
|
||||||
|
|
||||||
runApp();
|
for await (const event of Deno.watchFs('.')) {
|
||||||
|
|
||||||
for await (const event of Deno.fsEvents('.')) {
|
|
||||||
if (event.kind !== "access") {
|
if (event.kind !== "access") {
|
||||||
if (timeout) clearTimeout(timeout);
|
if (timeout) clearTimeout(timeout);
|
||||||
timeout = setTimeout(runApp, throttle);
|
timeout = setTimeout(runApp, throttle);
|
||||||
|
|||||||
Reference in New Issue
Block a user