本文整理汇总了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);
}
示例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
}
示例3: toVmFile
toVmFile(file: string): string {
return path.win32.join("Z:", file)
}
示例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
示例5: spyOn
spyOn(path, 'join').and.callFake((...args: string[]) => { return path.win32.join(...args); });
示例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));
}
示例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));
}
示例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);
}