• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript pnpm-logger.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中pnpm-logger.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: adaptConfig

function adaptConfig (opts: StrictPnpmOptions) {
  const registryLog = logger('registry')
  return {
    proxy: {
      http: opts.proxy,
      https: opts.httpsProxy,
      localAddress: opts.localAddress
    },
    ssl: {
      certificate: opts.cert,
      key: opts.key,
      ca: opts.ca,
      strict: opts.strictSsl
    },
    retry: {
      count: opts.fetchRetries,
      factor: opts.fetchRetryFactor,
      minTimeout: opts.fetchRetryMintimeout,
      maxTimeout: opts.fetchRetryMaxtimeout
    },
    userAgent: opts.userAgent,
    log: Object.assign({}, registryLog, {
      verbose: registryLog.debug.bind(null, 'http'),
      http: registryLog.debug.bind(null, 'http'),
    }),
    defaultTag: opts.tag
  }
}
开发者ID:andreypopp,项目名称:pnpm,代码行数:28,代码来源:install.ts


示例2: require

import {fetchFromRemoteTarball, FetchOptions} from '../resolve/fetch'
import {ResolveResult} from '../resolve'
import logger from 'pnpm-logger'
import spawn = require('cross-spawn')

const gitLogger = logger('git')

export default async function fetchRes (res: ResolveResult, target: string, opts: FetchOptions): Promise<void> {
  if (res.tarball) {
    return fetchFromRemoteTarball(target, {
        shasum: res.shasum,
        tarball: res.tarball
      }, opts)
  }
  if (res.repo && res.ref) {
      return clone(res.repo, res.ref, target)
  }
  if (res.fetch) {
      return res.fetch(target)
  }
}

/**
 * clone a git repository.
 */
export async function clone (repo: string, ref: string, dest: string) {
  await new Promise((resolve, reject) => {
    const args = ['clone', '-b', ref, repo, dest, '--single-branch']
    gitLogger.debug(`cloning git repository from ${repo}`)
    const git = spawnGit(args)
    let errMsg = ''
开发者ID:andreypopp,项目名称:pnpm,代码行数:31,代码来源:fetchResolution.ts


示例3: npmRun

    }),
    defaultTag: opts.tag
  }
}

function npmRun (scriptName: string, pkgRoot: string) {
  const result = runScriptSync('npm', ['run', scriptName], {
    cwd: pkgRoot,
    stdio: 'inherit'
  })
  if (result.status !== 0) {
    process.exit(result.status)
  }
}

const lifecycleLogger = logger('lifecycle')

function installLogger (pkgId: string) {
  return (stream: string, line: string) => {
    const logLevel = stream === 'stderr' ? 'error' : 'info'
    lifecycleLogger[logLevel]({pkgId, line})
  }
}

function mapify (pkgs: string[] | Dependencies): Dependencies {
  if (!pkgs) return {}
  if (Array.isArray(pkgs)) {
    return pkgs.reduce((pkgsMap: Dependencies, pkgRequest: string) => {
      const matches = /(@?[^@]+)@(.*)/.exec(pkgRequest)
      if (!matches) {
        pkgsMap[pkgRequest] = '*'
开发者ID:andreypopp,项目名称:pnpm,代码行数:31,代码来源:install.ts


示例4: logger

import logger, {ProgressMessage} from 'pnpm-logger'

const progressLogger = logger('progress')

export default (loginfo: ProgressMessage) => progressLogger.debug(loginfo)
开发者ID:andreypopp,项目名称:pnpm,代码行数:5,代码来源:logInstallStatus.ts


示例5: require

import logger from 'pnpm-logger'
import path = require('path')
import byline = require('byline')
import spawn = require('cross-spawn')
import PATH = require('path-name')

const scriptLogger = logger('run_script')

export type RunScriptOptions = {
  cwd: string,
  log: Function
}

export default function runScript (command: string, args: string[], opts: RunScriptOptions) {
  opts = Object.assign({log: (() => {})}, opts)
  args = args || []
  const log = opts.log
  const script = `${command}${args.length ? ' ' + args.join(' ') : ''}`
  if (script) scriptLogger.debug('runscript', script)
  if (!command) return Promise.resolve()
  return new Promise((resolve, reject) => {
    const proc = spawn(command, args, {
      cwd: opts.cwd,
      env: createEnv(opts.cwd)
    })

    log('stdout', '$ ' + script)

    proc.on('error', reject)
    byline(proc.stdout).on('data', (line: Buffer) => log('stdout', line.toString()))
    byline(proc.stderr).on('data', (line: Buffer) => log('stderr', line.toString()))
开发者ID:andreypopp,项目名称:pnpm,代码行数:31,代码来源:runScript.ts


示例6: require

import mkdirp = require('mkdirp')
import logger from 'pnpm-logger'

const mkdirpLogger = logger('mkdirp')

/**
 * mkdir -p as a promise.
 */
export default function (path: string) {
  return new Promise((resolve, reject) => {
    mkdirpLogger.debug(path)
    mkdirp(path, (err: Error) => err ? reject(err) : resolve(path))
  })
}
开发者ID:andreypopp,项目名称:pnpm,代码行数:14,代码来源:mkdirp.ts


示例7: require

import cacheManager = require('cache-manager')
import fsStore = require('cache-manager-fs')
import thenify = require('thenify')
import logger from 'pnpm-logger'

const cacheLogger = logger('cache')

export type CacheOptions = {
  path: string,
  ttl: number,
}

export default function createCache (opts: CacheOptions) {
  const cacheManagerOpts = {
    store: fsStore,
    ttl: opts.ttl,
    maxsize: 1000 * 1000 * 1000, // 1Gb, the max size in bytes on disk
    path: opts.path,
    preventfill: opts.ttl === 0,
  }
  const diskCache = cacheManager.caching(cacheManagerOpts)

  const getCache = thenify(diskCache.get.bind(diskCache))
  const setCache = thenify(diskCache.set.bind(diskCache))

  return {
    set: <T>(key: string, value: T) => setCache(key, value, cacheManagerOpts),
    get: async function (id: string) {
      try {
        return await getCache(id, cacheManagerOpts)
      } catch (err) {
开发者ID:andreypopp,项目名称:pnpm,代码行数:31,代码来源:createCache.ts


示例8: createRemoteTarballFetcher

import logger, {LoggedPkg} from 'pnpm-logger'
import fs = require('fs')
import {Got} from '../network/got'
import logStatus from '../logging/logInstallStatus'
import {IncomingMessage} from 'http'
import * as unpackStream from 'unpack-stream'

const fetchLogger = logger('fetch')

export type FetchOptions = {
  loggedPkg: LoggedPkg,
  got: Got
}

export type PackageDist = {
  tarball: string,
  shasum?: string
}

export function createRemoteTarballFetcher (dist: PackageDist, opts: FetchOptions) {
  return (target: string) => fetchFromRemoteTarball(target, dist, opts)
}

export function createLocalTarballFetcher (dist: PackageDist) {
  return (target: string) => fetchFromLocalTarball(target, dist)
}

/**
 * Fetches a tarball `tarball` and extracts it into `dir`
 */
export async function fetchFromRemoteTarball (dir: string, dist: PackageDist, opts: FetchOptions) {
开发者ID:andreypopp,项目名称:pnpm,代码行数:31,代码来源:fetch.ts



注:本文中的pnpm-logger.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript appconfig.overrideConfiguration函数代码示例发布时间:2022-05-25
下一篇:
TypeScript pngjs.PNG.sync类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap