UNPKG

babel-plugin-import-separation

Version:
47 lines (37 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Configuration = exports.winPath = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * 生成lib下对应包的名字 * 规则为首字母小写后面如果有大写字母则转换为 - 加上对应的小写字母 * 【 Button组建 -> button, DatePicker -> data-picker】 * @param {string} _str 对应的间隔符号 会返回一个可以生成对应间隔符号的函数 * @return {func} 对应包的路径名称 */ var formatCamel = function formatCamel(_sym) { return function (_str) { if (_sym === false) return _str; var str = _str[0].toLowerCase() + _str.substr(1); return str.replace(/([A-Z])/g, function ($1) { return "".concat(_sym).concat($1.toLowerCase()); }); }; }; var winPath = function winPath(path) { return path.replace(/\\/g, '/'); }; exports.winPath = winPath; var Configuration = function Configuration(libraryName, libraryDirectory, style, camelSymbol, fileName, onlyStyle) { _classCallCheck(this, Configuration); this.libraryName = libraryName; this.libraryDirectory = typeof libraryDirectory === 'undefined' ? 'lib' : libraryDirectory; this.style = style || false; this.fileName = fileName || ''; this.camelSymbol = typeof camelSymbol === 'undefined' ? '-' : camelSymbol; this.onlyStyle = onlyStyle || false; this.formatHandler = formatCamel(this.camelSymbol); }; exports.Configuration = Configuration;