Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/integration/installExtension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ describe("--install-extension", () => {
const statInfo = await stat(pathToExtFolder)
expect(statInfo.isDirectory()).toBe(true)
}, 20000)
it("should use EXTENSIONS_GALLERY when set", async () => {
const extName = `author.extension-1.0.0`
const { stderr } = await runCodeServerCommand([...setupFlags, "--install-extension", extName], {
EXTENSIONS_GALLERY: "{}",
})
expect(stderr).toMatch("No extension gallery service configured")
})
})
9 changes: 7 additions & 2 deletions test/utils/runCodeServerCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import { promisify } from "util"
*
* A helper function for integration tests to run code-server commands.
*/
export async function runCodeServerCommand(argv: string[]): Promise<{ stdout: string; stderr: string }> {
export async function runCodeServerCommand(
argv: string[],
env?: NodeJS.ProcessEnv,
): Promise<{ stdout: string; stderr: string }> {
const CODE_SERVER_COMMAND = process.env.CODE_SERVER_PATH || path.resolve("../../release-standalone/bin/code-server")
const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`)
const { stdout, stderr } = await promisify(exec)(`${CODE_SERVER_COMMAND} ${argv.join(" ")}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1). This shell command depends on an uncontrolled [absolute path](2).
env: { ...process.env, ...env },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah I did not know { ...undefined } works. TIL.

Interestingly [ ...undefined ] does not work. I guess that is JavaScript for you! 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL JS is teaching us new things everyday 😂

})

return { stdout, stderr }
}