Merge branch 'master' of github.com:Eugeny/terminus

This commit is contained in:
Eugene Pankov
2017-04-30 13:42:32 +02:00
16 changed files with 123 additions and 75 deletions

View File

@@ -29,6 +29,6 @@ html
div
h1.terminus-title Terminus
.progress
.bar(style='width: 50%')
.bar(style='width: 0%')

View File

@@ -21,7 +21,7 @@ if ((<any>global).require('electron-is-dev')) {
}
findPlugins().then(async plugins => {
let pluginsModules = loadPlugins(plugins, (current, total) => {
let pluginsModules = await loadPlugins(plugins, (current, total) => {
(<HTMLElement>document.querySelector('.progress .bar')).style.width = 100 * current / total + '%'
})
let module = await getRootModule(pluginsModules)

View File

@@ -62,10 +62,11 @@ export async function findPlugins (): Promise<IPluginEntry[]> {
return foundPlugins
}
export function loadPlugins (foundPlugins: IPluginEntry[], progress: ProgressCallback): any[] {
export async function loadPlugins (foundPlugins: IPluginEntry[], progress: ProgressCallback): Promise<any[]> {
let plugins: any[] = []
progress(0, 1)
foundPlugins.forEach((foundPlugin, index) => {
let index = 0
for (let foundPlugin of foundPlugins) {
console.info(`Loading ${foundPlugin.name}: ${(<any>global).require.resolve(foundPlugin.path)}`)
progress(index, foundPlugins.length)
try {
@@ -74,7 +75,9 @@ export function loadPlugins (foundPlugins: IPluginEntry[], progress: ProgressCal
} catch (error) {
console.error(`Could not load ${foundPlugin.name}:`, error)
}
})
await delay(1)
index++
}
progress(1, 1)
return plugins
}