Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6792813ffe | ||
|
|
83373b6c7b | ||
|
|
ff02c8a5a4 | ||
|
|
a1f1822c64 | ||
|
|
20957dcda8 | ||
|
|
9ac5f17b1c | ||
|
|
2789b6b2e7 | ||
|
|
6219528dcb |
@@ -8,7 +8,7 @@ the following code runs `deno --allow-net example.ts` which is located in `/some
|
|||||||
|
|
||||||
|
|
||||||
```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,23 +1,19 @@
|
|||||||
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.watchFs('.')) {
|
||||||
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