@@ -45,7 +45,7 @@ interface PluginProps {
45
45
* @default no formatter
46
46
* @example "biome"
47
47
*/
48
- formatter ?: Formatter ;
48
+ formatter ?: Formatter ;
49
49
/**
50
50
* The cwd, defaults to process.cwd()
51
51
* @default process.cwd()
@@ -115,6 +115,7 @@ function fileNameToCamelCase(fileName: string): string {
115
115
const capitalizedWords = words . map ( ( word ) => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) ) ;
116
116
return capitalizedWords . join ( "" ) ;
117
117
}
118
+
118
119
/**
119
120
* Creates a single SVG file that contains all the icons
120
121
*/
@@ -158,7 +159,7 @@ async function generateSvgSprite({
158
159
svg . removeAttribute ( "width" ) ;
159
160
svg . removeAttribute ( "height" ) ;
160
161
return svg . toString ( ) . trim ( ) ;
161
- } ) ,
162
+ } )
162
163
) ;
163
164
const output = [
164
165
'<?xml version="1.0" encoding="UTF-8"?>' ,
@@ -173,7 +174,7 @@ async function generateSvgSprite({
173
174
return writeIfChanged (
174
175
outputPath ,
175
176
formattedOutput ,
176
- `🖼️ Generated SVG spritesheet in ${ chalk . green ( outputDirRelative ) } ` ,
177
+ `🖼️ Generated SVG spritesheet in ${ chalk . green ( outputDirRelative ) } `
177
178
) ;
178
179
}
179
180
@@ -194,21 +195,18 @@ async function lintFileContent(fileContent: string, formatter: Formatter | undef
194
195
stdinStream . push ( null ) ;
195
196
196
197
const { process } = exec ( formatter , options , { } ) ;
197
- if ( ! process ?. stdin ) {
198
+ if ( ! process ?. stdin ) {
198
199
return fileContent ;
199
200
}
200
201
stdinStream . pipe ( process . stdin ) ;
201
202
process . stderr ?. pipe ( stderr ) ;
202
- process . on ( "error" , ( ) => {
203
- return fileContent
203
+ process . on ( "error" , ( err ) => {
204
+ console . error ( `Error running formatter process: ${ err . message } ` ) ;
204
205
} ) ;
205
- const formattedContent = await new Promise < string > ( ( resolve ) => {
206
- process . stdout ?. on ( "data" , ( data ) => {
207
- resolve ( data . toString ( ) ) ;
208
- } ) ;
209
- process . stderr ?. on ( "data" , ( data ) => {
210
- resolve ( data . toString ( ) ) ;
211
- } ) ;
206
+
207
+ let formattedContent = "" ;
208
+ process . stdout ?. on ( "data" , ( data ) => {
209
+ formattedContent = formattedContent + data . toString ( ) ;
212
210
} ) ;
213
211
return new Promise < string > ( ( resolve ) => {
214
212
process . on ( "exit" , ( code ) => {
@@ -242,7 +240,7 @@ async function generateTypes({
242
240
const file = await writeIfChanged (
243
241
outputPath ,
244
242
formattedOutput ,
245
- `${ chalk . blueBright ( "TS" ) } Generated icon types in ${ chalk . green ( outputPath ) } ` ,
243
+ `${ chalk . blueBright ( "TS" ) } Generated icon types in ${ chalk . green ( outputPath ) } `
246
244
) ;
247
245
return file ;
248
246
}
@@ -270,16 +268,7 @@ export const iconsSpritesheet: (args: PluginProps | PluginProps[]) => any = (may
270
268
const configs = Array . isArray ( maybeConfigs ) ? maybeConfigs : [ maybeConfigs ] ;
271
269
const allSpriteSheetNames = configs . map ( ( config ) => config . fileName ?? "sprite.svg" ) ;
272
270
return configs . map ( ( config , i ) => {
273
- const {
274
- withTypes,
275
- inputDir,
276
- outputDir,
277
- typesOutputFile,
278
- fileName,
279
- cwd,
280
- iconNameTransformer,
281
- formatter,
282
- } = config ;
271
+ const { withTypes, inputDir, outputDir, typesOutputFile, fileName, cwd, iconNameTransformer, formatter } = config ;
283
272
const iconGenerator = async ( ) =>
284
273
generateIcons ( {
285
274
withTypes,
@@ -290,7 +279,7 @@ export const iconsSpritesheet: (args: PluginProps | PluginProps[]) => any = (may
290
279
iconNameTransformer,
291
280
formatter,
292
281
} ) ;
293
-
282
+
294
283
const workDir = cwd ?? process . cwd ( ) ;
295
284
return {
296
285
name : `icon-spritesheet-generator${ i > 0 ? i . toString ( ) : "" } ` ,
0 commit comments