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


TypeScript path.win32類代碼示例

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


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

示例1: urlFromPath

export default function urlFromPath(root, filepath) {
  if (!filepath.startsWith(root)) {
    throw new Error(`file path is not in root: ${filepath} (${root})`);
  }

  // On windows systems, convert filesystem path to URL by replacing slashes
  let isPlatformWin = /^win/.test(process.platform);
  let isExtendedLengthPath = /^\\\\\?\\/.test(filepath);
  let hasNonAscii = /[^\x00-\x80]+/.test(filepath);
  if (isPlatformWin && !isExtendedLengthPath && !hasNonAscii) {
    return path.win32.relative(root, filepath).replace(/\\/g, '/');
  }

  // Otherwise, just return the relative path between the two
  return path.relative(root, filepath);
}
開發者ID:chrisUsick,項目名稱:polymer-cli,代碼行數:16,代碼來源:url-from-path.ts

示例2: parseCliArgs

export function parseCliArgs(argv: string[]): CliArgTypes {
  // remove optional unix node call
  if (path.basename(argv[0] || '') === 'node') {
    argv.splice(0, 1)
  }

  // remove optional windows node call
  if (path.win32.basename(argv[0] || '') === 'node.exe') {
    argv.splice(0, 1)
  }

  // remove optional linux text-run call
  if (path.basename(argv[0] || '') === 'text-run') {
    argv.splice(0, 1)
  }

  // remove optional Windows CLI call
  if (argv[0] && argv[0].endsWith('dist\\cli\\cli.js')) {
    argv.splice(0, 1)
  }

  const result = minimist(argv, { boolean: 'offline' })
  const commands = result._ || []
  delete result._

  // extract command
  let command = ''
  if (availableCommands().includes(commands[0])) {
    command = commands[0]
    commands.splice(0, 1)
  } else {
    command = 'run'
  }
  result.command = command
  result.files = commands[0]

  return result
}
開發者ID:Originate,項目名稱:tutorial-runner,代碼行數:38,代碼來源:parse-cli-args.ts

示例3: toVmFile

 toVmFile(file: string): string {
   return path.win32.join("Z:", file)
 }
開發者ID:ledinhphuong,項目名稱:electron-builder,代碼行數:3,代碼來源:WineVm.ts

示例4:

        ext: ".txt",
        name: "file"
    });
    // returns
    //    '/home/user/dir/file.txt'

    path.posix.format({
        dir: "/home/user/dir",
        base: "file.txt"
    });
    // returns
    //    '/home/user/dir/file.txt'

    path.win32.format({
        root: "C:\\",
        dir: "C:\\home\\user\\dir",
        ext: ".txt",
        name: "file"
    });
    // returns
    //    'C:\home\user\dir\file.txt'

    path.win32.format({
        dir: "C:\\home\\user\\dir",
        base: "file.txt"
    });
    // returns
    //    'C:\home\user\dir\file.txt'
}

////////////////////////////////////////////////////
/// readline tests : https://nodejs.org/api/readline.html
開發者ID:Dru89,項目名稱:DefinitelyTyped,代碼行數:32,代碼來源:node-tests.ts

示例5: spyOn

 spyOn(path, 'join').and.callFake((...args: string[]) => { return path.win32.join(...args); });
開發者ID:marclaval,項目名稱:angular,代碼行數:1,代碼來源:reflector_host_spec.ts

示例6: shouldMapPaths

 private shouldMapPaths(remotePath: string): boolean {
     // Map paths only if localRoot/remoteRoot are set, and the remote path is absolute on some system
     return !!this._localRoot && !!this._remoteRoot && (path.posix.isAbsolute(remotePath) || path.win32.isAbsolute(remotePath) || utils.isFileUrl(remotePath));
 }
開發者ID:Microsoft,項目名稱:vscode-chrome-debug-core,代碼行數:4,代碼來源:remotePathTransformer.ts

示例7: join

/**
 * Cross-platform path.join
 */
function join(a: string, b: string): string {
    return a.match(/^[A-Za-z]:/) ?
        path.win32.join(a, b) :
        utils.forceForwardSlashes(path.posix.join(a, b));
}
開發者ID:Microsoft,項目名稱:vscode-chrome-debug-core,代碼行數:8,代碼來源:remotePathTransformer.ts

示例8: relative

/**
 * Cross-platform path.relative
 */
function relative(a: string, b: string): string {
    return a.match(/^[A-Za-z]:/) ?
        path.win32.relative(a, b) :
        path.posix.relative(a, b);
}
開發者ID:Microsoft,項目名稱:vscode-chrome-debug-core,代碼行數:8,代碼來源:remotePathTransformer.ts


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