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

TypeScript findup-sync类代码示例

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

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



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

示例1: opt

'use strict';

import * as os from 'os';
import * as path from 'path';

import * as opt from 'optimist';
import * as Promise from 'bluebird';
import * as findup from 'findup-sync';

import * as util from './util/util';
import TestRunner from './test/TestRunner';

Promise.longStackTraces();

let testerPkgPath = path.resolve(findup('package.json', { cwd: process.cwd() }));

let optimist = opt(process.argv);
optimist.boolean('single-thread');

optimist.boolean('changes');
optimist.default('changes', false);

optimist.boolean('dry');
optimist.default('dry', false);

optimist.boolean('headers');
optimist.default('headers', true);

optimist.boolean('tests');
optimist.default('tests', true);
开发者ID:rakatyal,项目名称:definition-tester,代码行数:30,代码来源:index.ts


示例2: findConfigurationPath

export function findConfigurationPath(suppliedConfigFilePath: string, inputFilePath: string) {
    if (suppliedConfigFilePath != null) {
        if (!fs.existsSync(suppliedConfigFilePath)) {
            throw new Error(`Could not find config file at: ${path.resolve(suppliedConfigFilePath)}`);
        } else {
            return path.resolve(suppliedConfigFilePath);
        }
    } else {
        // search for tslint.json from input file location
        let configFilePath = findup(CONFIG_FILENAME, { cwd: inputFilePath, nocase: true });
        if (configFilePath != null && fs.existsSync(configFilePath)) {
            return path.resolve(configFilePath);
        }

        // search for package.json with tslintConfig property
        configFilePath = findup("package.json", { cwd: inputFilePath, nocase: true });
        if (configFilePath != null && require(configFilePath).tslintConfig != null) {
            return path.resolve(configFilePath);
        }

        // search for tslint.json in home directory
        const homeDir = getHomeDir();
        if (homeDir != null) {
            configFilePath = path.join(homeDir, CONFIG_FILENAME);
            if (fs.existsSync(configFilePath)) {
                return path.resolve(configFilePath);
            }
        }

        // no path could be found
        return undefined;
    }
}
开发者ID:ManuelLangActelion,项目名称:tslint,代码行数:33,代码来源:configuration.ts


示例3: importer

  return function importer(url: string, prev: string) {
    const nodeSassOptions = this.options;

    // Create a context for the current importer run.
    // An importer run is different from an importer instance,
    // one importer instance can spawn infinite importer runs.
    if (!this.nodeSassOnceImporterContext) {
      this.nodeSassOnceImporterContext = { store: new Set() };
    }

    // Each importer run has it's own new store, otherwise
    // files already imported in a previous importer run
    // would be detected as multiple imports of the same file.
    const store = this.nodeSassOnceImporterContext.store;
    const includePaths = buildIncludePaths(
      nodeSassOptions.includePaths,
      prev,
    );

    let data = null;
    let filterPrefix: string = ``;
    let filteredContents: string|null = null;
    let cleanedUrl = cleanImportUrl(url);
    let resolvedUrl: string|null = null;
    const isPackageUrl = cleanedUrl.match(matchPackageUrl);

    if (isPackageUrl) {
      cleanedUrl = cleanedUrl.replace(matchPackageUrl, ``);

      const packageName = cleanedUrl.charAt(0) === `@`
        ? cleanedUrl.split(DIRECTORY_SEPARATOR).slice(0, 2).join(DIRECTORY_SEPARATOR)
        : cleanedUrl.split(DIRECTORY_SEPARATOR)[0];
      const normalizedPackageName = path.normalize(packageName);
      const packageSearchPath = path.join('node_modules', normalizedPackageName, `package.json`);
      const packagePath = path.dirname(findupSync(packageSearchPath, { cwd: options.cwd }));

      const escapedNormalizedPackageName = normalizedPackageName.replace(`\\`, `\\\\`);
      cleanedUrl = path.resolve(
        packagePath.replace(new RegExp(`${escapedNormalizedPackageName}$`), ``),
        path.normalize(cleanedUrl),
      );

      resolvedUrl = resolvePackageUrl(
        cleanedUrl,
        options.extensions,
        options.cwd,
        options.packageKeys,
      );

      if (resolvedUrl) {
        data = { file: resolvedUrl.replace(/\.css$/, ``) };
      }
    } else {
      resolvedUrl = resolveUrl(cleanedUrl, includePaths);
    }

    const nodeFilters = parseNodeFilters(url);
    const selectorFilters = parseSelectorFilters(url);
    const hasFilters = nodeFilters.length || selectorFilters.length;
    const globFilePaths = resolveGlobUrl(cleanedUrl, includePaths);
    const storeId = getStoreId(resolvedUrl, selectorFilters, nodeFilters);

    if (hasFilters) {
      filterPrefix = `${url.split(` from `)[0]} from `;
    }

    if (globFilePaths) {
      const contents = globFilePaths
        .filter((x) => !store.has(getStoreId(x, selectorFilters, nodeFilters)))
        .map((x) => `@import '${filterPrefix}${x}';`)
        .join(`\n`);

      return { contents };
    }

    if (store.has(storeId)) {
      return EMPTY_IMPORT;
    }

    if (resolvedUrl && hasFilters) {
      filteredContents = fs.readFileSync(resolvedUrl, { encoding: `utf8` });

      if (selectorFilters.length) {
        filteredContents = cssSelectorExtract.processSync({
          css: filteredContents,
          filters: selectorFilters,
          postcssSyntax,
          preserveLines: true,
        });
      }

      if (nodeFilters.length) {
        filteredContents = cssNodeExtract.processSync({
          css: filteredContents,
          filters: nodeFilters,
          customFilters: options.customFilters,
          postcssSyntax,
          preserveLines: true,
        });
      }
//.........这里部分代码省略.........
开发者ID:maoberlehner,项目名称:node-sass-magic-importer,代码行数:101,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fluent-ffmpeg类代码示例发布时间:2022-05-28
下一篇:
TypeScript find-port类代码示例发布时间: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