Skip to content

Commit

Permalink
fix(deps): remove mine
Browse files Browse the repository at this point in the history
  • Loading branch information
northword committed Dec 19, 2024
1 parent 8b5c473 commit 40ce4f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"esbuild": "^0.24.0",
"fs-extra": "^11.2.0",
"hookable": "^5.5.3",
"mime": "^4.0.4",
"octokit": "^4.0.2",
"std-env": "^3.8.0",
"tiny-update-notifier": "^2.0.0",
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/core/releaser/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Context } from "../../types/index.js";
import { readFile, stat } from "node:fs/promises";
import { basename, join } from "node:path";
import process from "node:process";
import mime from "mime";
import { Octokit } from "octokit";
import { glob } from "tinyglobby";
import { getMimeTypeByFileName } from "../../utils/mime.js";
import { ReleaseBase } from "./base.js";

export default class GitHub extends ReleaseBase {
Expand Down Expand Up @@ -94,7 +94,7 @@ export default class GitHub extends ReleaseBase {
release_id: releaseID,
data: await readFile(asset) as unknown as string,
headers: {
"content-type": mime.getType(asset) || "application/octet-stream",
"content-type": getMimeTypeByFileName(asset) || "application/octet-stream",
"content-length": (await stat(asset)).size,
},
name: basename(asset),
Expand Down
17 changes: 17 additions & 0 deletions src/utils/mime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { extname } from "node:path";

const mimeTypes: { [key: string]: string[] } = {
"application/json": ["json"],
"application/x-xpinstall": ["xpi"],
};

export function getMimeTypeByFileName(filename: string) {
const ext = extname(filename);

for (const type in mimeTypes) {
if (mimeTypes[type].includes(ext))
return type;
}

return undefined;
}

0 comments on commit 40ce4f1

Please sign in to comment.