UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

67 lines 2.25 kB
"use strict"; /* * Copyright (c) 2020, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Global = exports.Mode = void 0; const os = require("os"); const path = require("path"); const kit_1 = require("@salesforce/kit"); const fs_1 = require("./util/fs"); /** * Represents an environment mode. Supports `production`, `development`, `demo`, and `test` * with the default mode being `production`. * * To set the mode, `export SFDX_ENV=<mode>` in your current environment. */ var Mode; (function (Mode) { Mode["PRODUCTION"] = "production"; Mode["DEVELOPMENT"] = "development"; Mode["DEMO"] = "demo"; Mode["TEST"] = "test"; })(Mode = exports.Mode || (exports.Mode = {})); /** * Global constants, methods, and configuration. */ class Global { /** * Gets the current mode environment variable as a {@link Mode} instance. * * ``` * console.log(Global.getEnvironmentMode() === Mode.PRODUCTION); * ``` */ static getEnvironmentMode() { return Mode[kit_1.env.getKeyOf('SFDX_ENV', Mode, Mode.PRODUCTION, (value) => value.toUpperCase())]; } /** * Creates a directory within {@link Global.DIR}, or {@link Global.DIR} itself if the `dirPath` param * is not provided. This is resolved or rejected when the directory creation operation has completed. * * @param dirPath The directory path to be created within {@link Global.DIR}. */ static async createDir(dirPath) { dirPath = dirPath ? path.join(Global.DIR, dirPath) : Global.DIR; await fs_1.fs.mkdirp(dirPath, fs_1.fs.DEFAULT_USER_DIR_MODE); } } exports.Global = Global; /** * The global folder in which state is stored. */ Global.STATE_FOLDER = '.sfdx'; /** * The full system path to the global state folder. * * **See** {@link Global.STATE_FOLDER} */ Global.DIR = path.join(os.homedir(), Global.STATE_FOLDER); /** * The full system path to the global log file. */ Global.LOG_FILE_PATH = path.join(Global.DIR, 'sfdx.log'); //# sourceMappingURL=global.js.map