cli-stash
Version:
CLI application to manage and work with Atlassian Stash. Work with your Stash project and repositories from Command lines.
56 lines (55 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathUtils = void 0;
const strUtils_1 = require("./strUtils");
const path = require("path");
const os = require("os");
/**
* Class with Utils methods for handle paths
*/
class PathUtils {
/**
* Method to get the file name from a path
* @param {string} filePath path to process
* @param {string} [extension] file extension to remove
*
* @returns {string} Returns the file name
*/
static getBasename(filePath, extension) {
return path.basename(filePath, extension);
}
/**
* Method to get an absolute path from a file or folder path and replace \\ characters with /
* @param {string} filePath path to process
*
* @returns {string} Returns the absolute file path
*/
static getAbsolutePath(filePath) {
return strUtils_1.StrUtils.replace(path.resolve(filePath), '\\', '/');
}
/**
* Method to get the directory name from a path
* @param {string} filePath path to process
*
* @returns {string} Return the folder name
*/
static getDirname(filePath) {
return strUtils_1.StrUtils.replace(path.dirname(filePath), '\\', '/');
}
/**
* Method to remove a file extension from file path
* @param {string} file file to process
*
* @returns {string} Returns the path without extension file
*/
static removeFileExtension(file) {
return file.split('.').slice(0, -1).join('.');
}
static getFileExtension(file) {
return path.extname(file);
}
static homeDir() {
return os.homedir();
}
}
exports.PathUtils = PathUtils;