fix: removed unefficient AI generated call pattern using one-use object types created for 2-3 variable passing.
Some checks failed
build / build (push) Failing after 13s
Some checks failed
build / build (push) Failing after 13s
This commit is contained in:
@@ -8,21 +8,16 @@ import readline from "node:readline";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
type RunAzOptions = {
|
||||
quiet?: boolean;
|
||||
allowFailure?: boolean;
|
||||
};
|
||||
|
||||
type RunAzResult = {
|
||||
status: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
};
|
||||
|
||||
function runAz(args: string[], options: RunAzOptions = {}): RunAzResult {
|
||||
function runAz(args: string[], quiet = false, allowFailure = false): RunAzResult {
|
||||
const result = spawnSync("az", args, {
|
||||
encoding: "utf8",
|
||||
stdio: options.quiet
|
||||
stdio: quiet
|
||||
? ["ignore", "ignore", "ignore"]
|
||||
: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
@@ -31,7 +26,7 @@ function runAz(args: string[], options: RunAzOptions = {}): RunAzResult {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
if (result.status !== 0 && options.allowFailure !== true) {
|
||||
if (result.status !== 0 && allowFailure !== true) {
|
||||
throw new Error(
|
||||
(result.stderr || "").trim() || `az ${args.join(" ")} failed`,
|
||||
);
|
||||
@@ -198,7 +193,7 @@ Options:
|
||||
"--enable-id-token-issuance",
|
||||
"true",
|
||||
],
|
||||
{ quiet: true },
|
||||
true,
|
||||
);
|
||||
} catch {
|
||||
console.error(
|
||||
@@ -210,14 +205,12 @@ Options:
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
runAz(["ad", "sp", "create", "--id", appId], {
|
||||
quiet: true,
|
||||
allowFailure: true,
|
||||
});
|
||||
runAz(["ad", "sp", "create", "--id", appId], true, true);
|
||||
|
||||
const adminConsentResult = runAz(
|
||||
["ad", "app", "permission", "admin-consent", "--id", appId],
|
||||
{ quiet: true, allowFailure: true },
|
||||
true,
|
||||
true,
|
||||
);
|
||||
if (adminConsentResult.status !== 0) {
|
||||
console.warn(
|
||||
|
||||
Reference in New Issue
Block a user