UNPKG

@azure/identity

Version:

Provides credential implementations for Azure SDK libraries that can authenticate with Microsoft Entra ID

49 lines 1.44 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { execFile, isProcessError, } from "@azure/core-process"; function outputToString(output) { if (output === undefined) { return ""; } return Buffer.isBuffer(output) ? output.toString("utf8") : output; } /** * Easy to mock childProcess utils. * @internal */ export const processUtils = { /** * Executes a file and preserves output when the process exits nonzero. * * @internal */ async execFileWithResult(file, params, options) { try { const result = await execFile(file, params, options); return { ...result, error: null }; } catch (error) { if (isProcessError(error)) { return { stdout: outputToString(error.stdout), stderr: outputToString(error.stderr), error, }; } throw error; } }, /** * Executes a file and rejects when it writes to stderr or exits nonzero. * * @internal */ async execFile(file, params, options) { const { stdout, stderr, error } = await processUtils.execFileWithResult(file, params, options); if (stderr || error) { throw stderr ? new Error(stderr) : error; } return stdout; }, }; //# sourceMappingURL=processUtils.js.map