Urara-Blog/node_modules/.pnpm-store/v3/files/dc/ae031ed24c881eba7b9a86d741c53a6e310776590f0e273a68a582c443acbd3bdf4803456ca0b7a858011d1812aec5b88421e73eb7ec7141075efd08d05913
2022-08-14 01:14:53 +08:00

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;