Skip to content

Commit 50b9391

Browse files
committed
- Fix extra command constant that's not correctly mapped
- Rename to CONSTANT_CASE for module level enums' value
1 parent b580e0c commit 50b9391

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/commands.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,12 @@ export function registerToolchainCommands(
6565
}
6666

6767
export enum Commands {
68-
ResolveDependencies = "swift.resolveDependencies",
69-
UpdateDependencies = "swift.updateDependencies",
70-
RunTestsMultipleTimes = "swift.runTestsMultipleTimes",
71-
ResetPackage = "swift.resetPackage",
72-
UseLocalDependency = "swift.useLocalDependency",
73-
UneditDependency = "swift.uneditDependency",
74-
runTestsMultipleTimes = "runTestsMultipleTimes",
68+
RESOLVE_DEPENDENCIES = "swift.resolveDependencies",
69+
UPDATE_DEPENDENCIES = "swift.updateDependencies",
70+
RUN_TESTS_MULTIPLE_TIMES = "swift.runTestsMultipleTimes",
71+
RESET_PACKAGE = "swift.resetPackage",
72+
USE_LOCAL_DEPENDENCY = "swift.useLocalDependency",
73+
UNEDIT_DEPENDENCY = "swift.uneditDependency",
7574
}
7675

7776
/**
@@ -80,14 +79,16 @@ export enum Commands {
8079
export function register(ctx: WorkspaceContext): vscode.Disposable[] {
8180
return [
8281
vscode.commands.registerCommand("swift.newFile", uri => newSwiftFile(uri)),
83-
vscode.commands.registerCommand(Commands.ResolveDependencies, () =>
82+
vscode.commands.registerCommand(Commands.RESOLVE_DEPENDENCIES, () =>
8483
resolveDependencies(ctx)
8584
),
86-
vscode.commands.registerCommand(Commands.UpdateDependencies, () => updateDependencies(ctx)),
85+
vscode.commands.registerCommand(Commands.UPDATE_DEPENDENCIES, () =>
86+
updateDependencies(ctx)
87+
),
8788
vscode.commands.registerCommand("swift.run", () => runBuild(ctx)),
8889
vscode.commands.registerCommand("swift.debug", () => debugBuild(ctx)),
8990
vscode.commands.registerCommand("swift.cleanBuild", () => cleanBuild(ctx)),
90-
vscode.commands.registerCommand(Commands.RunTestsMultipleTimes, item => {
91+
vscode.commands.registerCommand(Commands.RUN_TESTS_MULTIPLE_TIMES, item => {
9192
if (ctx.currentFolder) {
9293
return runTestMultipleTimes(ctx.currentFolder, item, false);
9394
}
@@ -99,7 +100,7 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
99100
}),
100101
// Note: This is only available on macOS (gated in `package.json`) because its the only OS that has the iOS SDK available.
101102
vscode.commands.registerCommand("swift.switchPlatform", () => switchPlatform()),
102-
vscode.commands.registerCommand(Commands.ResetPackage, () => resetPackage(ctx)),
103+
vscode.commands.registerCommand(Commands.RESET_PACKAGE, () => resetPackage(ctx)),
103104
vscode.commands.registerCommand("swift.runScript", () => runSwiftScript(ctx)),
104105
vscode.commands.registerCommand("swift.openPackage", () => {
105106
if (ctx.currentFolder) {
@@ -116,7 +117,7 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
116117
vscode.commands.registerCommand("swift.insertFunctionComment", () =>
117118
insertFunctionComment(ctx)
118119
),
119-
vscode.commands.registerCommand(Commands.UseLocalDependency, item => {
120+
vscode.commands.registerCommand(Commands.USE_LOCAL_DEPENDENCY, item => {
120121
if (item instanceof PackageNode) {
121122
return useLocalDependency(item.name, ctx);
122123
}
@@ -126,7 +127,7 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
126127
return editDependency(item.name, ctx);
127128
}
128129
}),
129-
vscode.commands.registerCommand(Commands.UneditDependency, item => {
130+
vscode.commands.registerCommand(Commands.UNEDIT_DEPENDENCY, item => {
130131
if (item instanceof PackageNode) {
131132
return uneditDependency(item.name, ctx);
132133
}

test/integration-tests/commands/dependency.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ suite("Dependency Commmands Test Suite", function () {
4343
});
4444

4545
test("Contract: spm resolve", async () => {
46-
const result = await vscode.commands.executeCommand(Commands.ResolveDependencies);
46+
const result = await vscode.commands.executeCommand(Commands.RESOLVE_DEPENDENCIES);
4747
expect(result).to.be.true;
4848
});
4949

5050
test("Contract: spm update", async () => {
51-
const result = await vscode.commands.executeCommand(Commands.UpdateDependencies);
51+
const result = await vscode.commands.executeCommand(Commands.UPDATE_DEPENDENCIES);
5252
expect(result).to.be.true;
5353
});
5454
});
@@ -97,7 +97,10 @@ suite("Dependency Commmands Test Suite", function () {
9797
// Contract: spm edit with user supplied local version of dependency
9898
const windowMock = sinon.stub(vscode.window, "showOpenDialog");
9999
windowMock.resolves([testAssetUri("Swift-Markdown")]);
100-
const result = await vscode.commands.executeCommand(Commands.UseLocalDependency, item);
100+
const result = await vscode.commands.executeCommand(
101+
Commands.USE_LOCAL_DEPENDENCY,
102+
item
103+
);
101104
expect(result).to.be.true;
102105
windowMock.restore();
103106

@@ -112,15 +115,15 @@ suite("Dependency Commmands Test Suite", function () {
112115
await useLocalDependencyTest();
113116

114117
// Contract: spm reset
115-
const result = await vscode.commands.executeCommand(Commands.ResetPackage);
118+
const result = await vscode.commands.executeCommand(Commands.RESET_PACKAGE);
116119
expect(result).to.be.true;
117120
});
118121

119122
test("Use local dependency - Add to workspace - Unedit", async () => {
120123
await useLocalDependencyTest();
121124

122125
// Contract: spm unedit
123-
const result = await vscode.commands.executeCommand(Commands.UneditDependency, item);
126+
const result = await vscode.commands.executeCommand(Commands.UNEDIT_DEPENDENCY, item);
124127
expect(result).to.be.true;
125128
});
126129
});

test/integration-tests/testexplorer/TestExplorerIntegration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ suite("Test Explorer Suite", function () {
304304
// Stub the showInputBox method to return the input text
305305
windowMock.showInputBox.resolves(`${numIterations}`);
306306

307-
vscode.commands.executeCommand(Commands.runTestsMultipleTimes, testItems[0]);
307+
vscode.commands.executeCommand(Commands.RUN_TESTS_MULTIPLE_TIMES, testItems[0]);
308308

309309
const testRun = await eventPromise(testExplorer.onCreateTestRun);
310310

@@ -419,7 +419,7 @@ suite("Test Explorer Suite", function () {
419419
// Stub the showInputBox method to return the input text
420420
windowMock.showInputBox.resolves(`${numIterations}`);
421421

422-
vscode.commands.executeCommand(Commands.runTestsMultipleTimes, testItems[0]);
422+
vscode.commands.executeCommand(Commands.RUN_TESTS_MULTIPLE_TIMES, testItems[0]);
423423

424424
const testRun = await eventPromise(testExplorer.onCreateTestRun);
425425

0 commit comments

Comments
 (0)