File tree Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Expand file tree Collapse file tree 4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 8383 "esbuild" : " ^0.24.0" ,
8484 "fs-extra" : " ^11.2.0" ,
8585 "hookable" : " ^5.5.3" ,
86- "mime" : " ^4.0.4" ,
8786 "octokit" : " ^4.0.2" ,
8887 "std-env" : " ^3.8.0" ,
8988 "tiny-update-notifier" : " ^2.0.0" ,
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import type { Context } from "../../types/index.js";
22import { readFile , stat } from "node:fs/promises" ;
33import { basename , join } from "node:path" ;
44import process from "node:process" ;
5- import mime from "mime" ;
65import { Octokit } from "octokit" ;
76import { glob } from "tinyglobby" ;
7+ import { getMimeTypeByFileName } from "../../utils/mime.js" ;
88import { ReleaseBase } from "./base.js" ;
99
1010export default class GitHub extends ReleaseBase {
@@ -94,7 +94,7 @@ export default class GitHub extends ReleaseBase {
9494 release_id : releaseID ,
9595 data : await readFile ( asset ) as unknown as string ,
9696 headers : {
97- "content-type" : mime . getType ( asset ) || "application/octet-stream" ,
97+ "content-type" : getMimeTypeByFileName ( asset ) || "application/octet-stream" ,
9898 "content-length" : ( await stat ( asset ) ) . size ,
9999 } ,
100100 name : basename ( asset ) ,
Original file line number Diff line number Diff line change 1+ import { extname } from "node:path" ;
2+
3+ const mimeTypes : { [ key : string ] : string [ ] } = {
4+ "application/json" : [ "json" ] ,
5+ "application/x-xpinstall" : [ "xpi" ] ,
6+ } ;
7+
8+ export function getMimeTypeByFileName ( filename : string ) {
9+ const ext = extname ( filename ) ;
10+
11+ for ( const type in mimeTypes ) {
12+ if ( mimeTypes [ type ] . includes ( ext ) )
13+ return type ;
14+ }
15+
16+ return undefined ;
17+ }
You can’t perform that action at this time.
0 commit comments