依赖安装日志增加安装时间

This commit is contained in:
whyour 2021-10-24 11:11:23 +08:00
parent 0842d66c79
commit 7dece938c8
3 changed files with 22 additions and 6 deletions

View File

@ -7,7 +7,6 @@ export default defineConfig({
nodeModulesTransform: { nodeModulesTransform: {
type: 'none', type: 'none',
}, },
mfsu: {},
fastRefresh: {}, fastRefresh: {},
favicon: '/images/g5.ico', favicon: '/images/g5.ico',
proxy: { proxy: {

View File

@ -32,7 +32,7 @@ export default async () => {
for (const key in groups) { for (const key in groups) {
if (Object.prototype.hasOwnProperty.call(groups, key)) { if (Object.prototype.hasOwnProperty.call(groups, key)) {
const group = groups[key]; const group = groups[key];
dependenceService.installOrUninstallDependencies(group); dependenceService.reInstall(group.map((x) => x._id));
} }
} }
}); });

View File

@ -191,12 +191,20 @@ export default class DependenceService {
)[dependencies[0].type as any]; )[dependencies[0].type as any];
const depIds = dependencies.map((x) => x._id) as string[]; const depIds = dependencies.map((x) => x._id) as string[];
const cp = spawn(`${depRunCommand} ${depNames}`, { shell: '/bin/bash' }); const cp = spawn(`${depRunCommand} ${depNames}`, { shell: '/bin/bash' });
const startTime = Date.now();
this.sockService.sendMessage({ this.sockService.sendMessage({
type: 'installDependence', type: 'installDependence',
message: `开始安装依赖 ${depNames}`, message: `开始安装依赖 ${depNames},开始时间 ${new Date(
startTime,
).toLocaleString()}`,
references: depIds, references: depIds,
}); });
this.updateLog(depIds, `开始安装依赖 ${depNames}\n`); this.updateLog(
depIds,
`开始安装依赖 ${depNames},开始时间 ${new Date(
startTime,
).toLocaleString()}\n`,
);
cp.stdout.on('data', (data) => { cp.stdout.on('data', (data) => {
this.sockService.sendMessage({ this.sockService.sendMessage({
type: 'installDependence', type: 'installDependence',
@ -225,12 +233,21 @@ export default class DependenceService {
}); });
cp.on('close', (code) => { cp.on('close', (code) => {
const endTime = Date.now();
this.sockService.sendMessage({ this.sockService.sendMessage({
type: 'installDependence', type: 'installDependence',
message: '依赖安装结束', message: `依赖安装结束,结束时间 ${new Date(
endTime,
).toLocaleString()} ${(endTime - startTime) / 1000} `,
references: depIds, references: depIds,
}); });
isInstall && this.updateLog(depIds, '依赖安装结束'); isInstall &&
this.updateLog(
depIds,
`依赖安装结束,结束时间 ${new Date(endTime).toLocaleString()},耗时 ${
(endTime - startTime) / 1000
} `,
);
isInstall && isInstall &&
this.dependenceDb.update( this.dependenceDb.update(
{ _id: { $in: depIds } }, { _id: { $in: depIds } },