mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-05 02:50:00 +00:00
provide legacy requires for terminus-* modules
This commit is contained in:
parent
db8c534d0a
commit
4569126322
@ -39,21 +39,23 @@ const builtinModules = [
|
|||||||
|
|
||||||
export type ProgressCallback = (current: number, total: number) => void // eslint-disable-line @typescript-eslint/no-type-alias
|
export type ProgressCallback = (current: number, total: number) => void // eslint-disable-line @typescript-eslint/no-type-alias
|
||||||
|
|
||||||
|
const cachedBuiltinModules = {}
|
||||||
|
|
||||||
export function initModuleLookup (userPluginsPath: string): void {
|
export function initModuleLookup (userPluginsPath: string): void {
|
||||||
global['module'].paths.map((x: string) => nodeModule.globalPaths.push(normalizePath(x)))
|
global['module'].paths.map((x: string) => nodeModule.globalPaths.push(normalizePath(x)))
|
||||||
|
|
||||||
|
nodeModule.globalPaths.unshift(path.join(userPluginsPath, 'node_modules'))
|
||||||
|
|
||||||
if (process.env.TABBY_DEV) {
|
if (process.env.TABBY_DEV) {
|
||||||
nodeModule.globalPaths.unshift(path.dirname(remote.app.getAppPath()))
|
nodeModule.globalPaths.unshift(path.dirname(remote.app.getAppPath()))
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeModule.globalPaths.unshift(builtinPluginsPath)
|
nodeModule.globalPaths.unshift(builtinPluginsPath)
|
||||||
nodeModule.globalPaths.unshift(path.join(userPluginsPath, 'node_modules'))
|
|
||||||
// nodeModule.globalPaths.unshift(path.join((process as any).resourcesPath, 'app.asar', 'node_modules'))
|
// nodeModule.globalPaths.unshift(path.join((process as any).resourcesPath, 'app.asar', 'node_modules'))
|
||||||
if (process.env.TABBY_PLUGINS) {
|
if (process.env.TABBY_PLUGINS) {
|
||||||
process.env.TABBY_PLUGINS.split(':').map(x => nodeModule.globalPaths.push(normalizePath(x)))
|
process.env.TABBY_PLUGINS.split(':').map(x => nodeModule.globalPaths.push(normalizePath(x)))
|
||||||
}
|
}
|
||||||
|
|
||||||
const cachedBuiltinModules = {}
|
|
||||||
builtinModules.forEach(m => {
|
builtinModules.forEach(m => {
|
||||||
cachedBuiltinModules[m] = nodeRequire(m)
|
cachedBuiltinModules[m] = nodeRequire(m)
|
||||||
})
|
})
|
||||||
@ -151,6 +153,7 @@ export async function findPlugins (): Promise<PluginInfo[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foundPlugins.sort((a, b) => a.name > b.name ? 1 : -1)
|
foundPlugins.sort((a, b) => a.name > b.name ? 1 : -1)
|
||||||
|
foundPlugins.sort((a, b) => a.isBuiltin < b.isBuiltin ? 1 : -1)
|
||||||
return foundPlugins
|
return foundPlugins
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +166,9 @@ export async function loadPlugins (foundPlugins: PluginInfo[], progress: Progres
|
|||||||
progress(index, foundPlugins.length)
|
progress(index, foundPlugins.length)
|
||||||
try {
|
try {
|
||||||
const packageModule = nodeRequire(foundPlugin.path)
|
const packageModule = nodeRequire(foundPlugin.path)
|
||||||
|
if (foundPlugin.packageName.startsWith('tabby-')) {
|
||||||
|
cachedBuiltinModules[foundPlugin.packageName.replace('tabby-', 'terminus-')] = packageModule
|
||||||
|
}
|
||||||
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
||||||
pluginModule.pluginName = foundPlugin.name
|
pluginModule.pluginName = foundPlugin.name
|
||||||
pluginModule.bootstrap = packageModule.bootstrap
|
pluginModule.bootstrap = packageModule.bootstrap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user