Unify version gathering

This commit is contained in:
mrjvs
2024-01-10 19:28:20 +01:00
parent 5a3268fd29
commit ba83059d43
2 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import type { PlasmoMessaging } from '@plasmohq/messaging';
import { getVersion } from '~hooks/useVersion';
import type { BaseRequest } from '~types/request';
import type { BaseResponse } from '~types/response';
import { assertDomainWhitelist } from '~utils/storage';
@@ -11,8 +12,7 @@ type Response = BaseResponse<{
const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (req, res) => {
try {
await assertDomainWhitelist(req.body.requestDomain);
const version = chrome.runtime.getManifest().version;
const version = getVersion();
res.send({
success: true,

View File

@@ -1,4 +1,8 @@
export function useVersion(ops?: { prefixed?: boolean }) {
export function getVersion(ops?: { prefixed?: boolean }) {
const prefix = ops?.prefixed ? 'v' : '';
return `${prefix}${chrome.runtime.getManifest().version}`;
}
export function useVersion(ops?: { prefixed?: boolean }) {
return getVersion(ops);
}