Add working directory to plugin config
This commit is contained in:
parent
3211eb1ce5
commit
00cfd9bdf1
@ -65,6 +65,7 @@ export class PluginAPI {
|
|||||||
*/
|
*/
|
||||||
private readonly csPlugin = "",
|
private readonly csPlugin = "",
|
||||||
private readonly csPluginPath = `${path.join(util.paths.data, "plugins")}:/usr/share/code-server/plugins`,
|
private readonly csPluginPath = `${path.join(util.paths.data, "plugins")}:/usr/share/code-server/plugins`,
|
||||||
|
private readonly workingDirectory: string | undefined = undefined,
|
||||||
) {
|
) {
|
||||||
this.logger = logger.named("pluginapi")
|
this.logger = logger.named("pluginapi")
|
||||||
}
|
}
|
||||||
@ -249,6 +250,7 @@ export class PluginAPI {
|
|||||||
|
|
||||||
p.init({
|
p.init({
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
workingDirectory: this.workingDirectory,
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.debug("loaded")
|
logger.debug("loaded")
|
||||||
|
@ -145,7 +145,8 @@ export const register = async (
|
|||||||
app.use("/static", _static.router)
|
app.use("/static", _static.router)
|
||||||
app.use("/update", update.router)
|
app.use("/update", update.router)
|
||||||
|
|
||||||
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH)
|
const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined
|
||||||
|
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
|
||||||
await papi.loadPlugins()
|
await papi.loadPlugins()
|
||||||
papi.mount(app, wsApp)
|
papi.mount(app, wsApp)
|
||||||
app.use("/api/applications", apps.router(papi))
|
app.use("/api/applications", apps.router(papi))
|
||||||
|
5
typings/pluginapi.d.ts
vendored
5
typings/pluginapi.d.ts
vendored
@ -212,6 +212,11 @@ export interface PluginConfig {
|
|||||||
* All plugin logs should be logged via this logger.
|
* All plugin logs should be logged via this logger.
|
||||||
*/
|
*/
|
||||||
readonly logger: Logger
|
readonly logger: Logger
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugins should default to this directory when applicable.
|
||||||
|
*/
|
||||||
|
readonly workingDirectory?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user