Skip to content

Commit

Permalink
feat(cli): This change allows to install pre-release version of the e…
Browse files Browse the repository at this point in the history
…xtensions to the test instance when available in the marketplace
  • Loading branch information
Sergio Herrera Gonzalez committed Oct 25, 2024
1 parent 6b40587 commit 65876b9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/Test-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Options:
-s, --storage <storage> # Use this folder for all test resources
-e, --extensions_dir <extensions_directory> # VS Code will use this directory for managing extensions
-t, --type <type> # Type of VS Code release (stable/insider)
-p, --pre_release # Installs the pre-release version of the extension
-h, --help # display help for command
```

Expand Down
3 changes: 2 additions & 1 deletion packages/extester/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ program
.option('-s, --storage <storage>', 'Use this folder for all test resources')
.option('-e, --extensions_dir <extensions_directory>', 'VS Code will use this directory for managing extensions')
.option('-t, --type <type>', 'Type of VS Code release (stable/insider)')
.option('-p, --pre_release', 'Installs the pre-release version of the extension')
.action(
withErrors(async (id, ids, cmd) => {
const extest = new ExTester(cmd.storage, codeStream(cmd.type), cmd.extensions_dir);
await extest.installFromMarketplace(id);
await extest.installFromMarketplace(id, cmd.pre_release);
if (ids && ids.length > 0) {
for (const idx of ids) {
await extest.installFromMarketplace(idx);
Expand Down
4 changes: 2 additions & 2 deletions packages/extester/src/extester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export class ExTester {
* Install an extension from VS Code marketplace into the test instance
* @param id id of the extension to install
*/
async installFromMarketplace(id: string): Promise<void> {
return this.code.installExtension(undefined, id);
async installFromMarketplace(id: string, preRelease = false): Promise<void> {
return this.code.installExtension(undefined, id, preRelease);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions packages/extester/src/util/codeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export class CodeUtil {
/**
* Install your extension into the test instance of VS Code
*/
installExtension(vsix?: string, id?: string): void {
installExtension(vsix?: string, id?: string, preRelease = false): void {
const pjson = require(path.resolve('package.json'));
if (id) {
return this.installExt(id);
return this.installExt(id, preRelease);
}
const vsixPath = path.resolve(vsix ? vsix : `${pjson.name}-${pjson.version}.vsix`);
this.installExt(vsixPath);
Expand Down Expand Up @@ -186,8 +186,11 @@ export class CodeUtil {
}
}

private installExt(pathOrID: string): void {
private installExt(pathOrID: string, preRelease = false): void {
let command = `${this.getCliInitCommand()} --force --install-extension "${pathOrID}"`;
if(preRelease){
command += " --pre-release";
}
if (this.extensionsFolder) {
command += ` --extensions-dir=${this.extensionsFolder}`;
}
Expand Down

0 comments on commit 65876b9

Please sign in to comment.