mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
chore: Better error message
This commit is contained in:
@@ -13,9 +13,10 @@ type Daemon<Ids extends string, Command extends string, Id extends string> = {
|
|||||||
fn: () => Promise<CheckResult> | CheckResult
|
fn: () => Promise<CheckResult> | CheckResult
|
||||||
trigger?: Trigger
|
trigger?: Trigger
|
||||||
}
|
}
|
||||||
requires?: Exclude<Ids, Id>[]
|
requires: Exclude<Ids, Id>[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ErrorDuplicateId<Id extends string> = `The id "${Id}" is already used`
|
||||||
/**
|
/**
|
||||||
* Used during the main of a function, it allows us to describe and ensure a set of daemons are running.
|
* Used during the main of a function, it allows us to describe and ensure a set of daemons are running.
|
||||||
* With the dependency, we are using this like an init system, where we can ensure that a daemon is running
|
* With the dependency, we are using this like an init system, where we can ensure that a daemon is running
|
||||||
@@ -56,7 +57,12 @@ export class Daemons<Ids extends string> {
|
|||||||
return new Daemons<never>(config.effects, config.started)
|
return new Daemons<never>(config.effects, config.started)
|
||||||
}
|
}
|
||||||
addDaemon<Id extends string, Command extends string>(
|
addDaemon<Id extends string, Command extends string>(
|
||||||
id: "" extends Id ? never : Id extends Ids ? never : Id,
|
// prettier-ignore
|
||||||
|
id:
|
||||||
|
"" extends Id ? never :
|
||||||
|
ErrorDuplicateId<Id> extends Id ? never :
|
||||||
|
Id extends Ids ? ErrorDuplicateId<Id> :
|
||||||
|
Id,
|
||||||
newDaemon: Omit<Daemon<Ids, Command, Id>, "id">,
|
newDaemon: Omit<Daemon<Ids, Command, Id>, "id">,
|
||||||
) {
|
) {
|
||||||
const daemons = ((this?.daemons ?? []) as any[]).concat({
|
const daemons = ((this?.daemons ?? []) as any[]).concat({
|
||||||
@@ -98,7 +104,6 @@ export class Daemons<Ids extends string> {
|
|||||||
}
|
}
|
||||||
resolve(child)
|
resolve(child)
|
||||||
})
|
})
|
||||||
return child
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user