New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@jdfed/leo-utils

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jdfed/leo-utils

为 leo 及其生态提供的工具库

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
5
Created
Source

leo-utils

为 leo 及其生态提供的工具库

loadPkg

动态加载

基础使用

import { loadPkg } from '@leo/leo-utils';

(async () => {
  const puppeteer = await loadPkg('puppeteer', '10.0.0');
})();

高级使用

import { loadPkg, log } from '@leo/leo-utils';

(async () => {
  const puppeteer = await loadPkg('puppeteer', {
    version: '10.0.0',
    private: true,
    beforeInstall: () => {
      log.info('Log info when beforeInstall');
    },
    installSuccess: () => {
      log.success('Log info when installSuccess');
    },
    installFail: () => {
      log.error('Log info when installFail');
    },
  });
})();

API

loadPkg

属性名描述类型默认值
name安装路径string--
versionOrOptions版本号或相关配置string / object--
versionOrOptions.version版本号stringfalse
versionOrOptions.dev本次安装是否为开发模式booleanfalse
versionOrOptions.private是否将安装的包单独隔离booleanfalse
versionOrOptions.beforeInstall本次安装后执行的声明周期(name: string, version?: string) => void--
versionOrOptions.afterInstall本次安装前执行的声明周期(name: string, version?: string) => void`--

log

基于 signale 封装的 log 工具

基础使用

import { log } from '@leo/leo-utils';

log.error('');
log.fatal('');
log.fav('');
log.info('');
log.star('');
log.success('');
log.wait('');
log.warn('');
log.complete('');
log.pending('');
log.note('');
log.start('');
log.pause('');
log.debug('');
log.await('');
log.watch('');
log.log('');

高级使用

import { log } from '@leo/leo-utils';

// 在输出时标识你的作用域,用于区分输出
const myLog = log.scope('plugin scope');

myLog.info('info');

// [plugin scope] › ℹ  info      Info will has scope remark

注意

  • log.debug 是否输出由 leoConfig.isDebug 来控制,你可以通过使用 log.debug 来定位线上问题

FAQs

Package last updated on 15 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts