Skip to content

Commit 916f6eb

Browse files
authored
feat(cli): support subscription id (#15300)
* feat(cli): support subscription id * fix: coverage
1 parent 8e6814f commit 916f6eb

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

packages/cli/src/commands/models/provision.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
3-
import { CLICommand, CLIContext, InputsWithProjectPath } from "@microsoft/teamsfx-api";
3+
import {
4+
CLICommand,
5+
CLICommandOption,
6+
CLIContext,
7+
InputsWithProjectPath,
8+
} from "@microsoft/teamsfx-api";
49
import { QuestionNames, newResourceGroupOption } from "@microsoft/teamsfx-core";
510
import { getFxCore } from "../../activate";
611
import { commands } from "../../resource";
712
import { TelemetryEvent } from "../../telemetry/cliTelemetryEvents";
813
import { EnvOption, IgnoreLoadEnvOption, ProjectFolderOption } from "../common";
914

15+
const subscriptionOption: CLICommandOption = {
16+
name: "subscriptionId",
17+
questionName: "targetSubscriptionId",
18+
shortName: "sub",
19+
description: "Azure Subscription ID.",
20+
type: "string",
21+
required: false,
22+
default: "",
23+
};
24+
1025
export const provisionCommand: CLICommand = {
1126
name: "provision",
1227
description: commands.provision.description,

packages/cli/src/userInteraction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ class CLIUserInteraction implements UserInteraction {
638638
}): Promise<Result<string, FxError>> {
639639
return new Promise<Result<string, FxError>>((resolve) => {
640640
const isWindows = process.platform === "win32";
641-
const command = isWindows ? "cmd.exe" : "/bin/bash";
641+
const command = args.shell ? args.shell : isWindows ? "cmd.exe" : "/bin/bash";
642642
const commandArgs = isWindows ? ["/c", args.cmd] : ["-c", args.cmd];
643643
logger.info(`Executing task: ${args.cmd}`);
644644
let output = "";

packages/cli/tests/unit/ui2.tests.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,22 @@ describe("runCommand", () => {
329329
assert.isTrue(spawnStub.calledOnce);
330330
assert.equal(spawnStub.firstCall.args[0], "cmd.exe");
331331
});
332+
it("uses custom shell", async () => {
333+
const mockChildProcess = {
334+
on: sandbox.stub().callsFake((event, callback) => {
335+
if (event === "close") {
336+
callback(0);
337+
}
338+
}),
339+
};
340+
sandbox.stub(process, "platform").value("win32");
341+
sandbox.stub(logger, "info").returns();
342+
const spawnStub = sandbox.stub(child_process, "spawn").returns(mockChildProcess as any);
343+
const res = await UI.runCommand({ cmd: "echo hello", shell: "powershell.exe" });
344+
assert.isTrue(res.isOk());
345+
assert.isTrue(spawnStub.calledOnce);
346+
assert.equal(spawnStub.firstCall.args[0], "powershell.exe");
347+
});
332348
it("error linux", async () => {
333349
const mockChildProcess = {
334350
on: sandbox.stub().callsFake((event, callback) => {

0 commit comments

Comments
 (0)