mirror of
https://github.com/sst/opencode.git
synced 2025-09-09 14:40:41 +00:00
flag for disabling file watcher
This commit is contained in:
parent
2528d8cb88
commit
204801052a
2 changed files with 34 additions and 30 deletions
|
@ -3,6 +3,7 @@ import { Bus } from "../bus"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import { App } from "../app/app"
|
import { App } from "../app/app"
|
||||||
import { Log } from "../util/log"
|
import { Log } from "../util/log"
|
||||||
|
import { Flag } from "../flag/flag"
|
||||||
|
|
||||||
export namespace FileWatcher {
|
export namespace FileWatcher {
|
||||||
const log = Log.create({ service: "file.watcher" })
|
const log = Log.create({ service: "file.watcher" })
|
||||||
|
@ -16,9 +17,7 @@ export namespace FileWatcher {
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
const state = App.state(
|
||||||
export function init() {
|
|
||||||
App.state(
|
|
||||||
"file.watcher",
|
"file.watcher",
|
||||||
() => {
|
() => {
|
||||||
const app = App.use()
|
const app = App.use()
|
||||||
|
@ -47,6 +46,10 @@ export namespace FileWatcher {
|
||||||
async (state) => {
|
async (state) => {
|
||||||
state.watcher?.close()
|
state.watcher?.close()
|
||||||
},
|
},
|
||||||
)()
|
)
|
||||||
|
|
||||||
|
export function init() {
|
||||||
|
if (Flag.OPENCODE_DISABLE_WATCHER) return
|
||||||
|
state()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export namespace Flag {
|
export namespace Flag {
|
||||||
export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE")
|
export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE")
|
||||||
|
export const OPENCODE_DISABLE_WATCHER = truthy("OPENCODE_DISABLE_WATCHER")
|
||||||
|
|
||||||
function truthy(key: string) {
|
function truthy(key: string) {
|
||||||
const value = process.env[key]?.toLowerCase()
|
const value = process.env[key]?.toLowerCase()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue