[Updater > Module] Simplify logging, tweak events
This commit is contained in:
parent
d0562f856e
commit
ccbb3fbb62
1 changed files with 8 additions and 15 deletions
|
@ -160,7 +160,7 @@ const checkModules = async () => {
|
||||||
const rem = remote[name];
|
const rem = remote[name];
|
||||||
|
|
||||||
if (inst !== rem) {
|
if (inst !== rem) {
|
||||||
log('Modules', 'Update:', name, '|', inst, '->', rem);
|
log('Modules', 'Update:', name, inst, '->', rem);
|
||||||
doing++;
|
doing++;
|
||||||
|
|
||||||
downloadModule(name, rem);
|
downloadModule(name, rem);
|
||||||
|
@ -190,7 +190,7 @@ const downloadModule = async (name, ver) => {
|
||||||
total
|
total
|
||||||
}));
|
}));
|
||||||
|
|
||||||
log('Modules', 'Downloading', `${name}@${ver}`, 'from', url, 'to', path);
|
log('Modules', 'Downloading', `${name}@${ver}`);
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
try {
|
try {
|
||||||
|
@ -218,11 +218,8 @@ const downloadModule = async (name, ver) => {
|
||||||
downloading.done++;
|
downloading.done++;
|
||||||
|
|
||||||
if (downloading.done === downloading.total) {
|
if (downloading.done === downloading.total) {
|
||||||
const succeeded = downloading.total - downloading.fail;
|
|
||||||
log('Modules', 'Done downloads', `| ${succeeded}/${downloading.total} success`);
|
|
||||||
|
|
||||||
events.emit('downloading-modules-finished', {
|
events.emit('downloading-modules-finished', {
|
||||||
succeeded,
|
succeeded: downloading.total - downloading.fail,
|
||||||
failed: downloading.fail
|
failed: downloading.fail
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -236,7 +233,7 @@ const installModule = async (name, ver, path) => {
|
||||||
name
|
name
|
||||||
});
|
});
|
||||||
|
|
||||||
log('Modules', 'Installing', `${name}@${ver}`, 'from', path);
|
// log('Modules', 'Installing', `${name}@${ver}`);
|
||||||
|
|
||||||
let hasError;
|
let hasError;
|
||||||
|
|
||||||
|
@ -305,20 +302,18 @@ const finishInstall = (name, ver, success) => {
|
||||||
if (!success) installing.fail++;
|
if (!success) installing.fail++;
|
||||||
|
|
||||||
events.emit('installed-module', {
|
events.emit('installed-module', {
|
||||||
name
|
name,
|
||||||
|
succeeded: true
|
||||||
});
|
});
|
||||||
|
|
||||||
installing.done++;
|
installing.done++;
|
||||||
log('Modules', 'Finished', `${name}@${ver}`);
|
log('Modules', 'Finished', `${name}@${ver}`);
|
||||||
|
|
||||||
if (installing.done === (downloading.total || installing.done)) {
|
if (installing.done === downloading.total) {
|
||||||
const succeeded = installing.total - installing.fail;
|
|
||||||
log('Modules', 'Done installs', `| ${succeeded}/${installing.total} success`);
|
|
||||||
|
|
||||||
if (!installing.fail) lastUpdate = Date.now();
|
if (!installing.fail) lastUpdate = Date.now();
|
||||||
|
|
||||||
events.emit('installing-modules-finished', {
|
events.emit('installing-modules-finished', {
|
||||||
succeeded,
|
succeeded: installing.total - installing.fail,
|
||||||
failed: installing.fail
|
failed: installing.fail
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -360,8 +355,6 @@ exports.install = (name, def, { version } = {}) => {
|
||||||
if (isInstalled(name, version)) {
|
if (isInstalled(name, version)) {
|
||||||
if (!def) events.emit('installed-module', {
|
if (!def) events.emit('installed-module', {
|
||||||
name,
|
name,
|
||||||
current: 1,
|
|
||||||
total: 1,
|
|
||||||
succeeded: true
|
succeeded: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue