bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
39 lines (33 loc) • 845 B
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = calculateFileInfo;
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
/**
* get the current working dir name of file and file name.
* @name fileInfo
* @param relativePath
* @returns {object}
* @example
* ```js
* currentDirName() // => 'bit'
* ```
*/
function calculateFileInfo(relativePath) {
const fileInfo = path().parse(relativePath);
const fullPath = path().dirname(relativePath);
const rootDir = path().dirname(fullPath);
const parentDir = path().relative(rootDir, fullPath);
return {
PARENT: parentDir,
FILE_NAME: fileInfo.name
};
}
;