slicejs-cli 1.0.29 → 1.0.30
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default function formatComponentCode(componentContent) {
|
|
2
|
+
// Eliminar espacios en blanco redundantes
|
|
3
|
+
componentContent = componentContent.replace(/\n\s*\n/g, '\n\n');
|
|
4
|
+
|
|
5
|
+
// Agregar espacios en blanco después de llaves y paréntesis
|
|
6
|
+
componentContent = componentContent.replace(/(\{|;|\(|\)|\})/g, '$1\n ');
|
|
7
|
+
|
|
8
|
+
// Eliminar espacios en blanco al final de las líneas
|
|
9
|
+
componentContent = componentContent.replace(/\s+$/gm, '');
|
|
10
|
+
|
|
11
|
+
// Reemplazar múltiples espacios con uno solo
|
|
12
|
+
componentContent = componentContent.replace(/ {2,}/g, ' ');
|
|
13
|
+
|
|
14
|
+
return componentContent.trim() + '\n';
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import Validations from '../Validations.js';
|
|
4
|
-
|
|
4
|
+
import formatComponentCode from '../format.js';
|
|
5
5
|
const __dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
6
6
|
|
|
7
7
|
|
|
@@ -64,6 +64,7 @@ function modifyComponent(componentName, category, addProperties, removePropertie
|
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
componentContent = updateComponentProps(componentContent, existingProperties);
|
|
67
|
+
componentContent = formatComponentCode(componentContent);
|
|
67
68
|
fs.writeFileSync(componentPath, componentContent);
|
|
68
69
|
console.log(`Component '${componentName}' modified successfully.`);
|
|
69
70
|
}
|