本文整理汇总了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
}
}
示例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 = ''
示例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] = '*'
示例4: logger
import logger, {ProgressMessage} from 'pnpm-logger'
const progressLogger = logger('progress')
export default (loginfo: ProgressMessage) => progressLogger.debug(loginfo)
示例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()))
示例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))
})
}
示例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) {
示例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) {