This commit is contained in:
Eugene Pankov
2017-04-28 22:40:58 +02:00
parent c7828e55f2
commit 94d8886d5a
15 changed files with 82 additions and 59 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

@@ -56,10 +56,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 {
@@ -68,7 +69,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
}