Skip to content

Commit

Permalink
✨ Feature: add global value for PicGo get GUI_VERSION & CORE_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Sep 28, 2020
1 parent bb90e17 commit eab014d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/apis/core/picgo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ picgo.saveConfig({
PICGO_ENV: 'GUI'
})

// @ts-ignore
picgo.GUI_VERSION = global.PICGO_GUI_VERSION

export default picgo! as PicGoCore
7 changes: 7 additions & 0 deletions src/main/utils/beforeOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import fs from 'fs-extra'
import path from 'path'
import os from 'os'
import { remote, app } from 'electron'
import pkg from 'root/package.json'

const APP = process.type === 'renderer' ? remote.app : app
const STORE_PATH = APP.getPath('userData')

function injectPicGoVersion () {
global.PICGO_GUI_VERSION = pkg.version
global.PICGO_CORE_VERSION = pkg.dependencies.picgo.replace('^', '')
}

function beforeOpen () {
injectPicGoVersion()
if (process.platform === 'darwin') {
resolveMacWorkFlow()
}
Expand Down
10 changes: 10 additions & 0 deletions src/universal/types/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ declare interface IWindowManager {
deleteById: (id: number) => void
getAvailableWindow: () => BrowserWindow
}

// https://stackoverflow.com/questions/35074713/extending-typescript-global-object-in-node-js/44387594#44387594
declare global {
namespace NodeJS {
interface Global {
PICGO_GUI_VERSION: string
PICGO_CORE_VERSION: string
}
}
}

0 comments on commit eab014d

Please sign in to comment.