Compare commits
No commits in common. "872a1c300967d0f6b6ccff3c5f32d95502ad413b" and "df700ffe912ff2bd77e995c4525448b774213bb6" have entirely different histories.
872a1c3009
...
df700ffe91
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"name": "nose_dir",
|
|
||||||
"type": "module",
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"hono": "^4.9.10"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/bun": "latest"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": "^5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
////
|
////
|
||||||
// version: df700ff
|
// version: c584db7
|
||||||
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __export = (target, all) => {
|
var __export = (target, all) => {
|
||||||
|
|
@ -83,12 +83,9 @@ __export(exports_scrollback, {
|
||||||
function randomId() {
|
function randomId() {
|
||||||
return Math.random().toString(36).slice(7);
|
return Math.random().toString(36).slice(7);
|
||||||
}
|
}
|
||||||
async function importUrl(url, cacheTag) {
|
async function importUrl(url) {
|
||||||
url += url.includes("?") ? "&" : "?";
|
url += url.includes("?") ? "&" : "?";
|
||||||
if (cacheTag)
|
url += "t=" + (nodeEnv() === "production" ? gitSHA() : Date.now());
|
||||||
url += "t=" + cacheTag;
|
|
||||||
else
|
|
||||||
url += "t=" + (nodeEnv() === "production" ? gitSHA() : Date.now());
|
|
||||||
console.log("-> import", url);
|
console.log("-> import", url);
|
||||||
return import(url);
|
return import(url);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { watch, readFileSync } from "fs"
|
||||||
import { join, basename } from "path"
|
import { join, basename } from "path"
|
||||||
import { isFile } from "./utils"
|
import { isFile } from "./utils"
|
||||||
import { sendAll } from "./websocket"
|
import { sendAll } from "./websocket"
|
||||||
import { expectDir, mtimeEpoch } from "./utils"
|
import { expectDir } from "./utils"
|
||||||
import { importUrl } from "./shared/utils"
|
import { importUrl } from "./shared/utils"
|
||||||
import type { Command, Commands } from "./shared/types"
|
import type { Command, Commands } from "./shared/types"
|
||||||
import { projectBin, projectName } from "./project"
|
import { projectBin, projectName } from "./project"
|
||||||
|
|
@ -82,11 +82,7 @@ export async function commandSource(name: string): Promise<string> {
|
||||||
export async function loadCommandModule(cmd: string) {
|
export async function loadCommandModule(cmd: string) {
|
||||||
const path = commandPath(cmd)
|
const path = commandPath(cmd)
|
||||||
if (!path) return
|
if (!path) return
|
||||||
|
return await importUrl(path)
|
||||||
if (path.startsWith(NOSE_DIR))
|
|
||||||
return await importUrl(path, await mtimeEpoch(path))
|
|
||||||
else
|
|
||||||
return await importUrl(path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let noseDirWatcher
|
let noseDirWatcher
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,10 @@ export function unique<T>(array: T[]): T[] {
|
||||||
return [...new Set(array)]
|
return [...new Set(array)]
|
||||||
}
|
}
|
||||||
|
|
||||||
// import a typescript module. caches by sha in production, doesn't cache in dev.
|
// import a typescript module. caches in production, doesn't in dev.
|
||||||
export async function importUrl(url: string, cacheTag?: string) {
|
export async function importUrl(url: string) {
|
||||||
url += url.includes("?") ? "&" : "?"
|
url += url.includes("?") ? "&" : "?"
|
||||||
if (cacheTag)
|
url += "t=" + (nodeEnv() === "production" ? gitSHA() : Date.now())
|
||||||
url += "t=" + cacheTag
|
|
||||||
else
|
|
||||||
url += "t=" + (nodeEnv() === "production" ? gitSHA() : Date.now())
|
|
||||||
|
|
||||||
console.log("-> import", url)
|
console.log("-> import", url)
|
||||||
return import(url)
|
return import(url)
|
||||||
|
|
|
||||||
|
|
@ -63,10 +63,6 @@ export async function mtime(path: string): Promise<Date> {
|
||||||
return mtime
|
return mtime
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mtimeEpoch(path: string): Promise<string> {
|
|
||||||
return (await mtime(path)).getTime().toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
// is the given file binary?
|
// is the given file binary?
|
||||||
export async function isBinaryFile(path: string): Promise<boolean> {
|
export async function isBinaryFile(path: string): Promise<boolean> {
|
||||||
// Create a stream to read just the beginning
|
// Create a stream to read just the beginning
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { readdirSync, watch } from "fs"
|
||||||
import { sendAll } from "./websocket"
|
import { sendAll } from "./websocket"
|
||||||
import { expectDir } from "./utils"
|
import { expectDir } from "./utils"
|
||||||
import { NOSE_DIR } from "./config"
|
import { NOSE_DIR } from "./config"
|
||||||
import { isFile, isDir, mtimeEpoch } from "./utils"
|
import { isFile, isDir } from "./utils"
|
||||||
import { importUrl } from "./shared/utils"
|
import { importUrl } from "./shared/utils"
|
||||||
|
|
||||||
export type Handler = (r: Context) => string | Child | Response | Promise<Response>
|
export type Handler = (r: Context) => string | Child | Response | Promise<Response>
|
||||||
|
|
@ -73,7 +73,7 @@ async function findApp(name: string): Promise<App | undefined> {
|
||||||
async function loadApp(path: string): Promise<App | undefined> {
|
async function loadApp(path: string): Promise<App | undefined> {
|
||||||
if (!await Bun.file(path).exists()) return
|
if (!await Bun.file(path).exists()) return
|
||||||
|
|
||||||
const mod = await importUrl(path, await mtimeEpoch(path))
|
const mod = await importUrl(path)
|
||||||
if (mod?.default)
|
if (mod?.default)
|
||||||
return mod.default as App
|
return mod.default as App
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user