mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
.
This commit is contained in:
@@ -14,6 +14,10 @@ export async function getRootModule(): Promise<any> {
|
||||
...(plugins.filter(x => x.bootstrap).map(x => x.bootstrap)),
|
||||
]
|
||||
|
||||
if (bootstrap.length == 0) {
|
||||
throw new Error('Did not find any bootstrap components. Are there any plugins installed?')
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports,
|
||||
bootstrap,
|
||||
|
@@ -1,26 +1,36 @@
|
||||
import * as fs from 'fs-promise'
|
||||
import * as path from 'path'
|
||||
const nodeModule = (<any>global).require('module')
|
||||
|
||||
function normalizePath (path: string): string {
|
||||
const cygwinPrefix = '/cygdrive/'
|
||||
if (path.startsWith(cygwinPrefix)) {
|
||||
path = path.substring(cygwinPrefix.length).replace('/', '\\')
|
||||
path = path[0] + ':' + path.substring(1)
|
||||
}
|
||||
return path
|
||||
};
|
||||
|
||||
(<any>global).require.main.paths.map(x => nodeModule.globalPaths.push(normalizePath(x)))
|
||||
|
||||
let nodeRequire = (<any>global).require
|
||||
let module = nodeRequire('module')
|
||||
nodeRequire.main.paths.map(x => module.globalPaths.push(x))
|
||||
if (process.env.TERMINUS_PLUGINS) {
|
||||
process.env.TERMINUS_PLUGINS.split(':').map(x => module.globalPaths.unshift(x))
|
||||
process.env.TERMINUS_PLUGINS.split(':').map(x => nodeModule.globalPaths.unshift(normalizePath(x)))
|
||||
}
|
||||
|
||||
export async function loadPlugins (): Promise<any[]> {
|
||||
let paths = module.globalPaths
|
||||
let paths = nodeModule.globalPaths
|
||||
let plugins: any[] = []
|
||||
for (let pluginDir of paths) {
|
||||
pluginDir = normalizePath(pluginDir)
|
||||
if (!await fs.exists(pluginDir)) {
|
||||
continue
|
||||
}
|
||||
for (let pluginName of await fs.readdir(pluginDir)) {
|
||||
if (/^terminus-/.exec(pluginName)) {
|
||||
let pluginPath = path.join(pluginDir, pluginName)
|
||||
console.info(`Loading ${pluginName}: ${nodeRequire.resolve(pluginPath)}`)
|
||||
console.info(`Loading ${pluginName}: ${(<any>global).require.resolve(pluginPath)}`)
|
||||
try {
|
||||
let pluginModule = nodeRequire(pluginPath)
|
||||
let pluginModule = (<any>global).require(pluginPath)
|
||||
plugins.push(pluginModule)
|
||||
} catch (error) {
|
||||
console.error(`Could not load ${pluginName}:`, error)
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./src",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"target": "es2015",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": false,
|
||||
|
Reference in New Issue
Block a user