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

TypeScript logger.getLogger函数代码示例

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

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



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

示例1: npmInstallAll

function npmInstallAll() {
    const logger = getLogger();

    logger.info('Couldn\'t find bundles. Running npm install');

    return npmWrapper.installAll();
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:7,代码来源:index.ts


示例2: clearNodeModules

async function clearNodeModules(): Promise<void> {
    const logger = getLogger();
    if (isRsyncModeEnabled) {
        return;
    }

    logger.trace(`moving node_modules to node_modules.bak.0`);

    let bodyCount = 0;
    let bakDirname;
    while (true) {
        bakDirname = `${nodeModules}.bak.${bodyCount}`;
        logger.trace(`moving node_modules to ${bakDirname}`);
        try {
            await fsExtra.stat(bakDirname);
            logger.trace(`${bakDirname} already exists; incrementing`);
            bodyCount++;
        } catch (err) {
            if (err.code && err.code === 'ENOENT') {
                await fsExtra.rename(nodeModules, bakDirname);
                logger.trace(`move was successful; removing ${bakDirname} without blocking`);
                return fsExtra.remove(bakDirname);
            }
        }
    }
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:26,代码来源:index.ts


示例3: nodeModulesAlreadyExist

async function nodeModulesAlreadyExist(): Promise<boolean> {
    const logger = getLogger();
    logger.trace('Checking node_modules');

    try {
        await fsExtra.access(nodeModules);
        logger.trace('\'node_modules\' directory already exists');
        return true
    } catch (err) {
        logger.trace('Node_modules not found');
        return false;
    }
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:13,代码来源:index.ts


示例4: provideBackendCallTools

export function provideBackendCallTools(backendConfig: BackendConfig, callType: BackendCalls): BackendToolsProvider {
    const controlToken = {};
    allTokens.push(controlToken);

    return {
        getLogger() {
            return getLogger();
        },

        getProgressStream(label?: string, total?: number) {
            const resultLabel = label ? `${backendConfig.alias} ${label}` : `${backendConfig.alias} ${callType}`;
            return new ProgressStream({}, resultLabel, controlToken, total);
        },
    };
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:15,代码来源:progress.ts


示例5: pullBackends

async function pullBackends(
    hash: string, config: Config, lockfilePath: string | null, backendIndex = 0
): Promise<PullInfo> {
    const logger = getLogger();
    const backendConfig = config.backends[backendIndex];

    if (!backendConfig) {
        throw new BundlesNotFoundError(`Backends don't have bundle ${hash}`);
    }

    logger.info(`Trying backend '${backendConfig.alias}' with hash ${hash}`);

    try {
        const cacheDirPath = await helpers.createCleanCacheDir(backendConfig);

        if (isRsyncModeEnabled) {
            await helpers.createCleanCwd(lockfilePath);
        }

        await backendConfig.backend.pull(
            hash, backendConfig.options, cacheDirPath,
            provideBackendCallTools(backendConfig, BackendCalls.push)
        );

        if (isRsyncModeEnabled) {
            logger.info(`Successfully fetched ${hash} from '${backendConfig.alias}'. Unpacking.`);

            const newNodeModules = path.resolve(process.cwd(), 'node_modules');
            helpers.restoreCWD();
            await rsyncWrapper.syncDirs(newNodeModules, process.cwd());
        }

        logger.info(`Pulled ${hash} from backend '${backendConfig.alias}'`);

        return {missingBackends: config.backends.slice(0, backendIndex)};
    } catch (error) {
        helpers.restoreCWD();

        if (error instanceof errors.BundleNotFoundError) {
            return pullBackends(hash, config, lockfilePath, backendIndex + 1);
        } else {
            logger.error(
                `Backend '${backendConfig.alias}' failed on pull:`
            );
            throw error;
        }
    }
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:48,代码来源:index.ts


示例6: installDiff

async function installDiff(oldPkgJson: PkgJson, newPkgJson: PkgJson): Promise<void> {
    const logger = getLogger();
    const allDepsOld = Object.assign({}, oldPkgJson.devDependencies, oldPkgJson.dependencies);
    const allDepsNew = Object.assign({}, newPkgJson.devDependencies, newPkgJson.dependencies);
    const depsDiff = objectDiff.diff(allDepsOld, allDepsNew);
    const depsToInstall = _.omitBy(depsDiff, _.isUndefined);
    const depsToUninstall = _.keys(_.pickBy(depsDiff, _.isUndefined));

    const loggingDepsToInstall = 'Installing dependencies: ' +
        Object.keys(depsToInstall).map(pkg => `${pkg}@${depsToInstall[pkg]}`).join(' ');

    const loggingDepsToUninstall = 'Uninstalling dependencies: ' + depsToUninstall.join(' ');

    if (_.keys(depsToInstall).length) {
        logger.info(loggingDepsToInstall);

        await npmWrapper.install(depsToInstall);
    }

    if (depsToUninstall.length) {
        logger.info(loggingDepsToUninstall);
        await npmWrapper.uninstall(depsToUninstall);
    }
}
开发者ID:mutantcornholio,项目名称:veendor,代码行数:24,代码来源:index.ts


示例7: install

export default async function install(
    {force = false, config, lockfilePath = null, rsyncMode = false}:
    {
        force: boolean, // remove node_modules if exist
        config: Config,
        lockfilePath: string | null, // path to lockfile, detected at startup. null, if no lockfile detected
        rsyncMode: boolean,
    }
): Promise<void> {
    const logger = getLogger();

    let backendsToPush: BackendConfig[] = [];

    const [rsyncAvailable, nodeModulesInPlace] = await Promise.all([
        rsyncWrapper.rsyncAvailable(),
        nodeModulesAlreadyExist(),
    ]);

    isRsyncModeEnabled = rsyncMode && rsyncAvailable && nodeModulesInPlace;

    if (isRsyncModeEnabled) {
        logger.info('Working in rsync mode');
    }

    const isGitRepo = await gitWrapper.isGitRepo(originalCwd);

    if (nodeModulesInPlace) {
        if (!force) {
            throw new NodeModulesAlreadyExistError();
        }

        if (!isRsyncModeEnabled) {
            logger.trace('Started removing node_modules');
            clearNodeModules().then(
                () => {logger.trace('Successfully removed node_modules');},
                err => {logger.debug(`Error during node_modules removal: ${err.stack}`);}
            );
        }
    }

    /**
     * Calculating current hash
     */
    let {hash, pkgJson} = await getFSHash(config, pkgJsonPath, lockfilePath);
    logger.info(`Got hash:\t${hash}`);

    /**
     * Downloading deps
     */
    let installStage: InstallStages = InstallStages.firstPull;
    let tryingHash = hash;
    let tryingPkgJson = pkgJson;
    let historyIndexStart = 0;
    while (true) {
        try {
            if (installStage === InstallStages.firstPull) {
                const info = await pullBackends(tryingHash, config, lockfilePath);
                backendsToPush = info.missingBackends;
                installStage = InstallStages.pushing;
                break;
            }

            if (installStage === InstallStages.pullFromGitHistory) {
                await pullBackends(tryingHash, config, lockfilePath);
                installStage = InstallStages.npmInstallDiff;
                continue;
            }

            if (installStage === InstallStages.npmInstallDiff) {
                await installDiff(tryingPkgJson, pkgJson);
                backendsToPush = config.backends;
                installStage = InstallStages.pushing;
                break;
            }

            if (installStage === InstallStages.npmInstallAll) {
                await npmInstallAll();
                backendsToPush = config.backends;
                installStage = InstallStages.pushing;
                break;
            }
        } catch (pullError) {
            if (pullError instanceof BundlesNotFoundError) {
                if (installStage === InstallStages.firstPull || installStage === InstallStages.pullFromGitHistory) {
                    if (configHasHistory(config) && isGitRepo) {
                        installStage = InstallStages.pullFromGitHistory;
                        try {
                            const res = await getHistoryHash(config, lockfilePath, tryingHash, historyIndexStart);
                            tryingHash = res.hash;
                            tryingPkgJson = res.pkgJson;
                            historyIndexStart = res.historyIndexEnd;
                            continue;
                        } catch (historyHashError) {
                            if (historyHashError instanceof BundlesNotFoundError) {
                                logger.trace(historyHashError);
                            }
                        }
                    }

                    if (!config.fallbackToNpm) {
//.........这里部分代码省略.........
开发者ID:mutantcornholio,项目名称:veendor,代码行数:101,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript debugTools.DebugWave类代码示例发布时间:2022-05-28
下一篇:
TypeScript munkres.default函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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