UNPKG

@ts-common/azure-js-dev-tools

Version:

Developer dependencies for TypeScript related projects

55 lines 1.87 kB
"use strict"; /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getBooleanArgument = exports.getArgument = void 0; var tslib_1 = require("tslib"); var yargs = tslib_1.__importStar(require("yargs")); function getArgument(argumentName, options) { if (options === void 0) { options = {}; } var result; var rawArgument = yargs.argv[argumentName]; if (rawArgument == undefined) { if (options.checkEnvironmentVariables) { var environmentVariableName = options.environmentVariableName || argumentName; rawArgument = process.env[environmentVariableName]; } if (rawArgument == undefined) { rawArgument = options.defaultValue; } } if (typeof rawArgument === "boolean") { result = rawArgument ? "true" : "false"; } else if (typeof rawArgument === "string") { result = rawArgument; } else if (Array.isArray(rawArgument) && rawArgument.length > 0) { result = rawArgument[rawArgument.length - 1]; } return result; } exports.getArgument = getArgument; function getBooleanArgument(argumentName, options) { if (options === void 0) { options = {}; } var rawArgument = getArgument(argumentName, { checkEnvironmentVariables: options.checkEnvironmentVariables, environmentVariableName: options.environmentVariableName }); var result; if (rawArgument === "true") { result = true; } else if (rawArgument === "false") { result = false; } else { result = options.defaultValue; } return result; } exports.getBooleanArgument = getBooleanArgument; //# sourceMappingURL=commandLine.js.map