mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-06 07:09:12 +08:00
31 lines
797 B
Text
31 lines
797 B
Text
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
const installPkg = require('@antfu/install-pkg');
|
|
const utils = require('@antfu/utils');
|
|
const kolorist = require('kolorist');
|
|
const loader_warn = require('./warn.cjs');
|
|
|
|
let pending;
|
|
const tasks = {};
|
|
async function tryInstallPkg(name) {
|
|
if (pending) {
|
|
await pending;
|
|
}
|
|
if (!tasks[name]) {
|
|
console.log(kolorist.cyan(`Installing ${name}...`));
|
|
tasks[name] = pending = installPkg.installPackage(name, {
|
|
dev: true,
|
|
preferOffline: true
|
|
}).then(() => utils.sleep(300)).catch((e) => {
|
|
loader_warn.warnOnce(`Failed to install ${name}`);
|
|
console.error(e);
|
|
}).finally(() => {
|
|
pending = void 0;
|
|
});
|
|
}
|
|
return tasks[name];
|
|
}
|
|
|
|
exports.tryInstallPkg = tryInstallPkg;
|