當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript is-windows類代碼示例

本文整理匯總了TypeScript中is-windows的典型用法代碼示例。如果您正苦於以下問題:TypeScript is-windows類的具體用法?TypeScript is-windows怎麽用?TypeScript is-windows使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了is-windows類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: isWindows

import * as isWindows from 'is-windows';

const bool: boolean = isWindows();
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:is-windows-tests.ts

示例2: isWindows

import * as isWindows from 'is-windows';

var bool: boolean = isWindows();
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:3,代碼來源:is-windows-tests.ts

示例3:

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

示例4: 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


注:本文中的is-windows類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。