Skip to content

Commit a6bb768

Browse files
committed
fix: fix lint file mime type detection
1 parent bf1a125 commit a6bb768

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

lib/lint/file.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,12 @@ export class LintFile {
353353

354354
type ||= customMime.findByFilename( this.#fullPath )?.essence;
355355

356-
type ||= (
357-
await customMime.findByShebang( {
358-
"path": this.#fullPath,
359-
"content": await this.#file.slice( 0, 50 ).text( "latin1" ),
360-
} )
361-
)?.essence;
362-
363-
type ||= this.#file.type;
356+
if ( !type ) {
357+
type =
358+
customMime.findByShebangSync( {
359+
"content": ( await this.#file.slice( 0, 50 ).buffer() ).toString( "latin1" ),
360+
} )?.essence || this.#file.type;
361+
}
364362

365363
this.#type = TYPES[ type ];
366364
}
@@ -373,7 +371,7 @@ export class LintFile {
373371
}
374372

375373
// read file content
376-
this.#originalData = this.#data = await this.#file.text( "utf8" );
374+
this.#originalData = this.#data = await this.#file.text();
377375

378376
// add default extension
379377
if ( this.#type ) {

0 commit comments

Comments
 (0)