[Updater > Module] Don't include unneeded things for emitted events
This commit is contained in:
parent
906c09289f
commit
da5c2d961b
|
@ -67,9 +67,7 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
events.emit('downloading-module', {
|
events.emit('downloading-module', {
|
||||||
name: 'host',
|
name: 'host'
|
||||||
current: 1,
|
|
||||||
total: 1
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -95,15 +93,11 @@ exports.init = (endpoint, { releaseChannel, version }) => {
|
||||||
checking = false;
|
checking = false;
|
||||||
|
|
||||||
events.emit('downloaded-module', {
|
events.emit('downloaded-module', {
|
||||||
name: 'host',
|
name: 'host'
|
||||||
current: 1,
|
|
||||||
total: 1,
|
|
||||||
succeeded: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
events.emit('downloading-modules-finished', {
|
events.emit('downloading-modules-finished', {
|
||||||
succeeded: 1,
|
succeeded: 1
|
||||||
failed: 0
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -182,9 +176,7 @@ const checkModules = async () => {
|
||||||
const downloadModule = async (name, ver) => {
|
const downloadModule = async (name, ver) => {
|
||||||
downloading.total++;
|
downloading.total++;
|
||||||
events.emit('downloading-module', {
|
events.emit('downloading-module', {
|
||||||
name,
|
name
|
||||||
current: downloading.total,
|
|
||||||
total: downloading.total
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const url = baseUrl + '/' + name + '/' + ver;
|
const url = baseUrl + '/' + name + '/' + ver;
|
||||||
|
@ -194,7 +186,6 @@ const downloadModule = async (name, ver) => {
|
||||||
|
|
||||||
stream.on('progress', ([ cur, total ]) => events.emit('downloading-module-progress', {
|
stream.on('progress', ([ cur, total ]) => events.emit('downloading-module-progress', {
|
||||||
name,
|
name,
|
||||||
progress: Math.min(100, Math.floor(100 * (cur / total))),
|
|
||||||
cur,
|
cur,
|
||||||
total
|
total
|
||||||
}));
|
}));
|
||||||
|
@ -220,9 +211,7 @@ const downloadModule = async (name, ver) => {
|
||||||
else downloading.fail++;
|
else downloading.fail++;
|
||||||
|
|
||||||
events.emit('downloaded-module', {
|
events.emit('downloaded-module', {
|
||||||
name,
|
name
|
||||||
current: downloading.total,
|
|
||||||
total: downloading.total
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,9 +233,7 @@ const downloadModule = async (name, ver) => {
|
||||||
const installModule = async (name, ver, path) => {
|
const installModule = async (name, ver, path) => {
|
||||||
installing.total++;
|
installing.total++;
|
||||||
events.emit('installing-module', {
|
events.emit('installing-module', {
|
||||||
name,
|
name
|
||||||
current: installing.total,
|
|
||||||
total: installing.total
|
|
||||||
});
|
});
|
||||||
|
|
||||||
log('Modules', 'Installing', `${name}@${ver}`, 'from', path);
|
log('Modules', 'Installing', `${name}@${ver}`, 'from', path);
|
||||||
|
@ -299,7 +286,6 @@ const installModule = async (name, ver, path) => {
|
||||||
cur++;
|
cur++;
|
||||||
events.emit('installing-module-progress', {
|
events.emit('installing-module-progress', {
|
||||||
name,
|
name,
|
||||||
progress: Math.min(100, Math.floor(cur / total * 100)),
|
|
||||||
cur,
|
cur,
|
||||||
total
|
total
|
||||||
});
|
});
|
||||||
|
@ -319,10 +305,7 @@ const finishInstall = (name, ver, success) => {
|
||||||
if (!success) installing.fail++;
|
if (!success) installing.fail++;
|
||||||
|
|
||||||
events.emit('installed-module', {
|
events.emit('installed-module', {
|
||||||
name,
|
name
|
||||||
current: installing.total,
|
|
||||||
total: installing.total,
|
|
||||||
succeeded: success
|
|
||||||
});
|
});
|
||||||
|
|
||||||
installing.done++;
|
installing.done++;
|
||||||
|
|
Loading…
Reference in New Issue