当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript findup-sync.default方法代码示例

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


在下文中一共展示了findup-sync.default方法的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.default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。