Skip to content

Commit 00cfd9b

Browse files
committed
Add working directory to plugin config
1 parent 3211eb1 commit 00cfd9b

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/node/plugin.ts

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class PluginAPI {
6565
*/
6666
private readonly csPlugin = "",
6767
private readonly csPluginPath = `${path.join(util.paths.data, "plugins")}:/usr/share/code-server/plugins`,
68+
private readonly workingDirectory: string | undefined = undefined,
6869
) {
6970
this.logger = logger.named("pluginapi")
7071
}
@@ -249,6 +250,7 @@ export class PluginAPI {
249250

250251
p.init({
251252
logger: logger,
253+
workingDirectory: this.workingDirectory,
252254
})
253255

254256
logger.debug("loaded")

src/node/routes/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export const register = async (
145145
app.use("/static", _static.router)
146146
app.use("/update", update.router)
147147

148-
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH)
148+
const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined
149+
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
149150
await papi.loadPlugins()
150151
papi.mount(app, wsApp)
151152
app.use("/api/applications", apps.router(papi))

typings/pluginapi.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ export interface PluginConfig {
212212
* All plugin logs should be logged via this logger.
213213
*/
214214
readonly logger: Logger
215+
216+
/**
217+
* Plugins should default to this directory when applicable.
218+
*/
219+
readonly workingDirectory?: string
215220
}
216221

217222
/**

0 commit comments

Comments
 (0)