本文整理匯總了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);
}