@zowe/cli
Version:
Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.
55 lines • 1.88 kB
JavaScript
;
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DaemonUtil = void 0;
const fs = require("fs");
const os = require("os");
const path = require("path");
const imperative_1 = require("@zowe/imperative");
/**
* Class containing daemon utility functions.
* @export
* @class DaemonUtil
*/
class DaemonUtil {
/**
* Get the directory that holds daemon-related runtime files.
* Ensures that the directory exists, or we create it.
*
* @returns The absolute path to the daemon directory.
*/
static getDaemonDir() {
var _a, _b;
let daemonDir;
if (((_b = (_a = process.env) === null || _a === void 0 ? void 0 : _a.ZOWE_DAEMON_DIR) === null || _b === void 0 ? void 0 : _b.length) > 0) {
// user can choose a daemon directory for storing runtime artifacts
daemonDir = process.env.ZOWE_DAEMON_DIR;
}
else {
// our default location.
daemonDir = path.join(os.homedir(), ".zowe", "daemon");
}
if (!imperative_1.IO.existsSync(daemonDir)) {
try {
imperative_1.IO.createDirSync(daemonDir);
const ownerReadWriteTraverse = 0o700;
fs.chmodSync(daemonDir, ownerReadWriteTraverse);
}
catch (err) {
throw new Error("Failed to create directory '" + daemonDir + "'\nDetails = " + err.message);
}
}
return daemonDir;
}
}
exports.DaemonUtil = DaemonUtil;
//# sourceMappingURL=DaemonUtil.js.map