unity-find-fault
Version:
A tool to find fault in unity project.
68 lines • 1.75 kB
JavaScript
import _ from "lodash";
import moment from "moment";
import ora from "ora";
export class Status {
static instance;
static get Instance() {
if (!Status.instance) {
Status.instance = new Status();
}
return Status.instance;
}
spinner = null;
taskName = '';
stage;
crtCnt = 0;
total = 0;
startAt = 0;
errors = [];
startTask(name, total) {
this.end();
this.taskName = name;
this.total = total;
this.startAt = _.now();
this.reset();
}
reset(stage) {
this.crtCnt = 0;
this.stage = stage;
this.spinner = ora(this.title).start(`${moment().format('HH:mm:ss')} ${this.title} (${this.crtCnt}/${this.total})`);
}
update(info) {
this.crtCnt++;
if (this.spinner != null) {
this.spinner.text = `${moment().format('HH:mm:ss')} ${this.title} (${this.crtCnt}/${this.total}): ${info}`;
}
}
end() {
if (this.spinner != null) {
this.spinner.succeed();
this.spinner = null;
}
this.taskName = '';
}
get title() {
let title = this.taskName;
if (this.stage != null)
title += ' ' + this.stage;
return title;
}
emptyErrors() {
this.errors.length = 0;
}
collect(error) {
if (this.spinner != null) {
this.errors.push(`[${this.title}] ${error}`);
}
else {
console.error(error);
}
}
dumpErrors() {
console.error('--------------------ERRORS--------------------');
for (const e of this.errors) {
console.error(e);
}
}
}
//# sourceMappingURL=Status.js.map