@cloud-ru/ft-gulp-icon-builder 1.0.1-preview-df9ff74.0 → 1.0.1-preview-9dae167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,10 @@ const capitalizeFirstLetter = (str) => {
22
22
  return str;
23
23
  return str.charAt(0).toUpperCase() + str.slice(1);
24
24
  };
25
+ const removeLeadingSlash = (str) => str.replace(/^\/+/, '');
25
26
  function gulpSvgIndexFile({ src, dest }) {
26
27
  const folders = {};
27
- const getTail = (fullPath) => fullPath.replace(`${node_path_1.default.resolve(process.cwd(), src)}/`, '');
28
+ const getTail = (fullPath) => removeLeadingSlash(fullPath.replace(node_path_1.default.resolve(process.cwd(), src), ''));
28
29
  return (0, createPipeTransformer_1.createPipeTransformer)({
29
30
  transformer: (file, _encoding, callback) => {
30
31
  const folder = file.dirname;
@@ -42,7 +43,9 @@ function gulpSvgIndexFile({ src, dest }) {
42
43
  }
43
44
  {
44
45
  // index file for icon folder
45
- const component = files.length === 2 ? (0, index_template_1.getComponent)(files, 'Component') : `export * from './${files[0].split('.')[0]}';`;
46
+ const component = files.length === 2
47
+ ? (0, index_template_1.getComponent)(files, 'Component')
48
+ : `export { default } from './${files[0].split('.')[0]}';`;
46
49
  const finalFilePath = node_path_1.default.resolve(dest, getTail(folder), 'index.tsx');
47
50
  node_fs_1.default.writeFileSync(finalFilePath, component);
48
51
  }
@@ -16,9 +16,10 @@ const capitalizeFirstLetter = (str) => {
16
16
  return str;
17
17
  return str.charAt(0).toUpperCase() + str.slice(1);
18
18
  };
19
+ const removeLeadingSlash = (str) => str.replace(/^\/+/, '');
19
20
  export function gulpSvgIndexFile({ src, dest }) {
20
21
  const folders = {};
21
- const getTail = (fullPath) => fullPath.replace(`${path.resolve(process.cwd(), src)}/`, '');
22
+ const getTail = (fullPath) => removeLeadingSlash(fullPath.replace(path.resolve(process.cwd(), src), ''));
22
23
  return createPipeTransformer({
23
24
  transformer: (file, _encoding, callback) => {
24
25
  const folder = file.dirname;
@@ -36,7 +37,9 @@ export function gulpSvgIndexFile({ src, dest }) {
36
37
  }
37
38
  {
38
39
  // index file for icon folder
39
- const component = files.length === 2 ? getComponent(files, 'Component') : `export * from './${files[0].split('.')[0]}';`;
40
+ const component = files.length === 2
41
+ ? getComponent(files, 'Component')
42
+ : `export { default } from './${files[0].split('.')[0]}';`;
40
43
  const finalFilePath = path.resolve(dest, getTail(folder), 'index.tsx');
41
44
  fs.writeFileSync(finalFilePath, component);
42
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ft-gulp-icon-builder",
3
- "version": "1.0.1-preview-df9ff74.0",
3
+ "version": "1.0.1-preview-9dae167.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  ""
@@ -46,5 +46,5 @@
46
46
  "@types/vinyl": "2.0.12",
47
47
  "gulp-cli": "3.1.0"
48
48
  },
49
- "gitHead": "c9d8d521a1fede651fad5e57d618849e24b61acb"
49
+ "gitHead": "d9a5d712461f1d0375f1cda6fcfbaaf2c06a44c0"
50
50
  }
@@ -14,10 +14,12 @@ const capitalizeFirstLetter = (str: string): string => {
14
14
  return str.charAt(0).toUpperCase() + str.slice(1);
15
15
  };
16
16
 
17
+ const removeLeadingSlash = (str: string): string => str.replace(/^\/+/, '');
18
+
17
19
  export function gulpSvgIndexFile({ src, dest }: Params) {
18
20
  const folders: Record<string, string[]> = {};
19
21
 
20
- const getTail = (fullPath: string) => fullPath.replace(`${path.resolve(process.cwd(), src)}/`, '');
22
+ const getTail = (fullPath: string) => removeLeadingSlash(fullPath.replace(path.resolve(process.cwd(), src), ''));
21
23
 
22
24
  return createPipeTransformer({
23
25
  transformer: (file, _encoding, callback) => {
@@ -41,7 +43,9 @@ export function gulpSvgIndexFile({ src, dest }: Params) {
41
43
  {
42
44
  // index file for icon folder
43
45
  const component =
44
- files.length === 2 ? getComponent(files, 'Component') : `export * from './${files[0].split('.')[0]}';`;
46
+ files.length === 2
47
+ ? getComponent(files, 'Component')
48
+ : `export { default } from './${files[0].split('.')[0]}';`;
45
49
  const finalFilePath = path.resolve(dest, getTail(folder), 'index.tsx');
46
50
  fs.writeFileSync(finalFilePath, component);
47
51
  }