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


TypeScript path.normalize函數代碼示例

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


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

示例1:

 newHost.fileExists = (fileName: string): boolean => {
   return path.normalize(fileName) == normalSyntheticIndexName || delegate.fileExists(fileName);
 };
開發者ID:Cammisuli,項目名稱:angular,代碼行數:3,代碼來源:bundle_index_host.ts

示例2: formFullAppPath

function formFullAppPath(name: string) {
  const prefix = 'C:/Program Files (x86)/Google/Chrome/Application'
  return normalize(join(prefix, `${name}.exe`))
}
開發者ID:lgandecki,項目名稱:cypress,代碼行數:4,代碼來源:index.ts

示例3: require

'use strict';

import destCopy from '../broccoli-dest-copy';
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
var renderLodashTemplate = require('broccoli-lodash');
var replace = require('broccoli-replace');
var stew = require('broccoli-stew');
var ts2dart = require('../broccoli-ts2dart');
import transpileWithTraceur from '../traceur/index';
import compileWithTypescript from '../broccoli-typescript';

var projectRootDir = path.normalize(path.join(__dirname, '..', '..', '..', '..'));


module.exports = function makeNodeTree(destinationPath) {
  // list of npm packages that this build will create
  var outputPackages = ['angular2', 'benchpress', 'rtts_assert'];

  var modulesTree = new Funnel('modules', {
    include: ['angular2/**', 'benchpress/**', 'rtts_assert/**', '**/e2e_test/**'],
    exclude: [
      // the following code and tests are not compatible with CJS/node environment
      'angular2/src/core/zone/vm_turn_zone.es6',
      'angular2/test/core/zone/**'
    ]
  });

  var nodeTree = transpileWithTraceur(modulesTree, {
    destExtension: '.js',
開發者ID:IlanFrumer,項目名稱:angular,代碼行數:31,代碼來源:node_tree.ts

示例4: exec

 .then(() => exec(normalize('node'), 'index.js'))
開發者ID:Serdji,項目名稱:angular-cli,代碼行數:1,代碼來源:platform-server.ts

示例5:

 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import * as path from 'path';
import * as assert from 'assert';

import { join, normalize } from 'vs/base/common/paths';
import * as platform from 'vs/base/common/platform';

import { FileWalker, Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
import { IRawFileMatch, IFolderSearch } from 'vs/workbench/services/search/node/search';
import { getPathFromAmdModule } from 'vs/base/common/amd';

const TEST_FIXTURES = path.normalize(getPathFromAmdModule(require, './fixtures'));
const EXAMPLES_FIXTURES = path.join(TEST_FIXTURES, 'examples');
const MORE_FIXTURES = path.join(TEST_FIXTURES, 'more');
const TEST_ROOT_FOLDER: IFolderSearch = { folder: TEST_FIXTURES };
const ROOT_FOLDER_QUERY: IFolderSearch[] = [
	TEST_ROOT_FOLDER
];

const ROOT_FOLDER_QUERY_36438: IFolderSearch[] = [
	{ folder: path.normalize(getPathFromAmdModule(require, './fixtures2/36438')) }
];

const MULTIROOT_QUERIES: IFolderSearch[] = [
	{ folder: EXAMPLES_FIXTURES },
	{ folder: MORE_FIXTURES }
];
開發者ID:developers23,項目名稱:vscode,代碼行數:31,代碼來源:search.test.ts

示例6: parseDependency

export function parseDependency (raw: string): Dependency {
  const [type, src] = splitProtocol(raw)

  // `file:path/to/file.d.ts`
  if (type === 'file') {
    const location = normalize(src)
    const filename = basename(location)
    const name = isDefinition(filename) ? pathFromDefinition(filename) : undefined

    invariant(
      filename === CONFIG_FILE || isDefinition(filename),
      `Only ".d.ts" and "${CONFIG_FILE}" files are supported`
    )

    return {
      raw,
      type,
      meta: {
        name: name,
        path: location
      },
      location
    }
  }

  // `bitbucket:org/repo/path#sha`
  if (type === 'github') {
    const meta = gitFromPath(src)
    const { org, repo, path, sha } = meta
    const location = `https://raw.githubusercontent.com/${org}/${repo}/${sha}/${path}`

    return {
      raw,
      meta,
      type,
      location
    }
  }

  // `bitbucket:org/repo/path#sha`
  if (type === 'bitbucket') {
    const meta = gitFromPath(src)
    const { org, repo, path, sha } = meta
    const location = `https://bitbucket.org/${org}/${repo}/raw/${sha}/${path}`

    return {
      raw,
      meta,
      type,
      location
    }
  }

  // `npm:dependency`, `npm:@scoped/dependency`
  if (type === 'npm') {
    const parts = src.split('/')
    const isScoped = parts.length > 0 && parts[0].charAt(0) === '@'
    const hasPath = isScoped ? parts.length > 2 : parts.length > 1

    if (!hasPath) {
      parts.push('package.json')
    }

    return {
      raw,
      type: 'npm',
      meta: {
        name: isScoped ? parts.slice(0, 2).join('/') : parts[0],
        path: join(...parts.slice(isScoped ? 2 : 1))
      },
      location: join(...parts)
    }
  }

  // `bower:dependency`
  if (type === 'bower') {
    const parts = src.split('/')

    if (parts.length === 1) {
      parts.push('bower.json')
    }

    return {
      raw,
      type: 'bower',
      meta: {
        name: parts[0],
        path: join(...parts.slice(1))
      },
      location: join(...parts)
    }
  }

  // `http://example.com/foo.d.ts`
  if (type === 'http' || type === 'https') {
    return {
      raw,
      type,
      meta: {},
      location: raw
//.........這裏部分代碼省略.........
開發者ID:timbrown81,項目名稱:core,代碼行數:101,代碼來源:parse.ts

示例7: catch

    {
        let str: string;
        let result: string;

        result = querystring.escape(str);
        result = querystring.unescape(str);
    }
}

////////////////////////////////////////////////////
/// path tests : http://nodejs.org/api/path.html
////////////////////////////////////////////////////

module path_tests {

    path.normalize('/foo/bar//baz/asdf/quux/..');

    path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
    // returns
    //'/foo/bar/baz/asdf'

    try {
        path.join('foo', {}, 'bar');
    }
    catch(error) {

    }

    path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile');
    //Is similar to:
    //
開發者ID:403016605,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:node-tests.ts

示例8:

import * as path from 'path';
import {getNodeEnv} from '../utils/express-utils';

const appName       = 'dungeonCrawler';
const defaultPort   = 3000;
const rootPath      = path.normalize(__dirname + '/../../..');

let variables: any = {
  development: {
    root: rootPath,
    app: {
      name: appName
    },
    port: defaultPort,
  },

  test: {
    root: rootPath,
    app: {
      name: appName
    },
    port: defaultPort,
  },

  production: {
    root: rootPath,
    app: {
      name: appName
    },
    port: defaultPort,
  }
開發者ID:simonxca,項目名稱:dungeon-crawler-v2,代碼行數:31,代碼來源:express-config.ts

示例9:

  // Set the __filename to the path of html file if it is file: protocol.
  if (window.location.protocol === 'file:') {
    const location = window.location
    let pathname = location.pathname

    if (process.platform === 'win32') {
      if (pathname[0] === '/') pathname = pathname.substr(1)

      const isWindowsNetworkSharePath = location.hostname.length > 0 && globalPaths[0].startsWith('\\')
      if (isWindowsNetworkSharePath) {
        pathname = `//${location.host}/${pathname}`
      }
    }

    global.__filename = path.normalize(decodeURIComponent(pathname))
    global.__dirname = path.dirname(global.__filename)

    // Set module's filename so relative require can work as expected.
    module.filename = global.__filename

    // Also search for module under the html file.
    module.paths = module.paths.concat(Module._nodeModulePaths(global.__dirname))
  } else {
    global.__filename = __filename
    global.__dirname = __dirname

    if (appPath) {
      // Search for module under the app directory
      module.paths = module.paths.concat(Module._nodeModulePaths(appPath))
    }
開發者ID:vwvww,項目名稱:electron,代碼行數:30,代碼來源:init.ts

示例10: testFilePath

function testFilePath(filename: string): string {
    return path.normalize(path.join(here, '../..', 'test', filename));
}
開發者ID:stanionascu,項目名稱:vscode-cmake-tools,代碼行數:3,代碼來源:extension.test.ts


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