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


TypeScript is-windows.default方法代码示例

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


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

示例1: dirname

    (specifier: string, documentPath: string, componentInfo?: {
      packageName: string,
      rootDir: string,
      componentDir: string
    }): FileRelativeUrl => {
      if (whatwgUrl.parseURL(specifier) !== null) {
        return specifier as FileRelativeUrl;
      }

      const importerFilepath = documentPath;

      const dependencyFilepath = nodeResolve.sync(specifier, {
        basedir: dirname(importerFilepath),

        // It's invalid to load a .json or .node file as a module on the web,
        // but this is what Node's resolution algorithm does
        // (https://nodejs.org/api/modules.html#modules_all_together), so we
        // also do it here for completeness. Without including these
        // extensions the user will probably get a 404. With them, they'll
        // probably get an invalid MIME type error (which is hopefully more
        // useful).
        extensions: ['.js', '.json', '.node'],

        // Some packages use a non-standard alternative to the "main" field
        // in their package.json to differentiate their ES module version.
        packageFilter:
            (packageJson:
                 {main?: string, module?: string, 'jsnext:main'?: string}) => {
              packageJson.main = packageJson.module ||
                  packageJson['jsnext:main'] || packageJson.main;
              return packageJson;
            },
      });

      let relativeSpecifierUrl =
          relative(dirname(importerFilepath), dependencyFilepath) as
          FileRelativeUrl;

      if (componentInfo !== undefined) {
        // Special handling for servers like Polyserve which, when serving a
        // package "foo", will map the URL "/components/foo" to the root package
        // directory, so that "foo" can make correct relative path references to
        // its dependencies.
        //
        // Note that Polyserve will only set componentInfo if the particular
        // request was for a URL path in the components/ directory.
        const {packageName, rootDir, componentDir} = componentInfo;

        const importerInRootPackage =
            !pathIsInside(importerFilepath, componentDir);

        const dependencyInRootPackage =
            !pathIsInside(dependencyFilepath, componentDir);

        if (importerInRootPackage && !dependencyInRootPackage) {
          // A module from the root package, served from a components/ URL, is
          // importing a module from a different package. In this case we need
          // to fix up our relative path specifier, because on disk the
          // dependency resolves to e.g. "./node_modules/foo", but in URL space
          // it must resolve to "../foo".
          //
          // Note that the case where both the importer and the dependency are
          // in the root package does not need to be fixed up, since the
          // relative path works out the same.
          const rootRelativeImporterPath = relative(rootDir, importerFilepath);
          const effectiveImporterFilepath =
              join(componentDir, packageName, rootRelativeImporterPath);
          relativeSpecifierUrl = relative(
                                     dirname(effectiveImporterFilepath),
                                     dependencyFilepath) as FileRelativeUrl;
        }
      }

      if (isWindows()) {
        // normalize path separators to URL format
        relativeSpecifierUrl =
            relativeSpecifierUrl.replace(/\\/g, '/') as FileRelativeUrl;
      }

      if (!isPathSpecifier(relativeSpecifierUrl)) {
        relativeSpecifierUrl = './' + relativeSpecifierUrl as FileRelativeUrl;
      }

      return relativeSpecifierUrl;
    };
开发者ID:MehdiRaash,项目名称:tools,代码行数:85,代码来源:resolve-specifier-node.ts

示例2: isWindows

import * as isWindows from 'is-windows';

const bool: boolean = isWindows();
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:3,代码来源:is-windows-tests.ts

示例3: isWindows

import * as isWindows from 'is-windows';

var bool: boolean = isWindows();
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:3,代码来源:is-windows-tests.ts

示例4:

import * as shell from 'shelljs';
import * as utils from "./script-utils";
import * as build from "./build";
import * as isWindows from "is-windows";
import chalk from 'chalk';

utils.exitIfNotRunFromRootDir();

//------------------------------------
utils.printTaskHeading('Checking your local environment');
if (isWindows()) {
  const scriptShell = shell.exec('npm config get script-shell', { silent: true }).stdout.toString().trim();
  if (!scriptShell.endsWith('bash.exe')) {
    console.log('');
    console.log(chalk.black.bgRedBright(`Warning!`) + chalk.redBright(` On Windows, we strongly recommend Git Bash as an npm script-shell.`));
    console.log('');
    console.log(chalk.whiteBright(`We detected your current script-shell is: ${scriptShell === 'null' ? 'cmd.exe' : scriptShell}`));
    console.log(chalk.whiteBright(`You can set a script-shell by running:`));
    console.log('');
    console.log(chalk.whiteBright(`    npm config set script-shell "c:\\Program Files\\git\\bin\\bash.exe"`));
  }
}

//------------------------------------
utils.printTaskHeading('Configuring git');
shell.exec('git config core.ignorecase false && git config core.filemode false');

//------------------------------------
utils.printTaskHeading('Installing dependencies in ext-libs');
shell.exec('composer install -d ext-libs --ignore-platform-reqs');
开发者ID:OddenCreative,项目名称:versionpress,代码行数:30,代码来源:init-dev.ts


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