state.js 738 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.expandState = expandState;
  4. var _path = _interopRequireDefault(require("path"));
  5. var _camelcase = _interopRequireDefault(require("camelcase"));
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7. const validCharacters = /[^a-zA-Z0-9_-]/g;
  8. function getComponentName(state) {
  9. if (!state.filePath) return 'SvgComponent';
  10. const pascalCaseFileName = (0, _camelcase.default)(_path.default.parse(state.filePath).name.replace(validCharacters, ''), {
  11. pascalCase: true
  12. });
  13. return `Svg${pascalCaseFileName}`;
  14. }
  15. function expandState(state) {
  16. return {
  17. componentName: state.componentName || getComponentName(state),
  18. ...state
  19. };
  20. }