nix-api
Version:
<div align="center"> <img src="./docs/.vuepress/public/images/logo.png" width="200px"> </div>
65 lines (53 loc) • 2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var File =
/*#__PURE__*/
function () {
function File(filepath) {
_classCallCheck(this, File);
this.dir = '';
this.base = '';
this.ext = '';
this.name = '';
this.parse(filepath);
}
_createClass(File, [{
key: "parse",
value: function parse(filepath) {
var parsed = _path.default.parse(filepath);
if (!parsed) return;
this.dir = this.cleanDir(parsed.dir);
this.base = parsed.base;
this.ext = parsed.ext;
this.name = parsed.name;
}
}, {
key: "cleanDir",
value: function cleanDir(dir) {
return dir.split(_path.default.sep).join('/');
}
}, {
key: "getPath",
value: function getPath() {
if (this.dir) return "".concat(this.dir, "/").concat(this.base);
return this.base;
}
}, {
key: "getPathWithoutExt",
value: function getPathWithoutExt() {
if (this.dir) return "".concat(this.dir, "/").concat(this.name);
return this.name;
}
}]);
return File;
}();
var _default = File;
exports.default = _default;