本文整理匯總了TypeScript中vs/base/common/path.win32類的典型用法代碼示例。如果您正苦於以下問題:TypeScript win32類的具體用法?TypeScript win32怎麽用?TypeScript win32使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了win32類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: extname
].forEach((test) => {
const expected = test[1];
[path.posix.extname, path.win32.extname].forEach((extname) => {
let input = test[0];
let os;
if (extname === path.win32.extname) {
input = input.replace(slashRE, '\\');
os = 'win32';
} else {
os = 'posix';
}
const actual = extname(input);
const message = `path.${os}.extname(${JSON.stringify(input)})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
if (actual !== expected) {
failures.push(`\n${message}`);
}
});
{
const input = `C:${test[0].replace(slashRE, '\\')}`;
const actual = path.win32.extname(input);
const message = `path.win32.extname(${JSON.stringify(input)})\n expect=${
JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
if (actual !== expected) {
failures.push(`\n${message}`);
}
}
});
示例2: assertDirname
function assertDirname(p: string, expected: string, win = false) {
const actual = win ? path.win32.dirname(p) : path.posix.dirname(p);
if (actual !== expected) {
assert.fail(`${p}: expected: ${expected}, ours: ${actual}`);
}
}
示例3:
].forEach(nonAbsolutePath => {
assert.ok(!path.win32.isAbsolute(nonAbsolutePath), nonAbsolutePath);
});
示例4: test
test('isAbsolute', () => {
assert.strictEqual(path.win32.isAbsolute('/'), true);
assert.strictEqual(path.win32.isAbsolute('//'), true);
assert.strictEqual(path.win32.isAbsolute('//server'), true);
assert.strictEqual(path.win32.isAbsolute('//server/file'), true);
assert.strictEqual(path.win32.isAbsolute('\\\\server\\file'), true);
assert.strictEqual(path.win32.isAbsolute('\\\\server'), true);
assert.strictEqual(path.win32.isAbsolute('\\\\'), true);
assert.strictEqual(path.win32.isAbsolute('c'), false);
assert.strictEqual(path.win32.isAbsolute('c:'), false);
assert.strictEqual(path.win32.isAbsolute('c:\\'), true);
assert.strictEqual(path.win32.isAbsolute('c:/'), true);
assert.strictEqual(path.win32.isAbsolute('c://'), true);
assert.strictEqual(path.win32.isAbsolute('C:/Users/'), true);
assert.strictEqual(path.win32.isAbsolute('C:\\Users\\'), true);
assert.strictEqual(path.win32.isAbsolute('C:cwd/another'), false);
assert.strictEqual(path.win32.isAbsolute('C:cwd\\another'), false);
assert.strictEqual(path.win32.isAbsolute('directory/directory'), false);
assert.strictEqual(path.win32.isAbsolute('directory\\directory'), false);
assert.strictEqual(path.posix.isAbsolute('/home/foo'), true);
assert.strictEqual(path.posix.isAbsolute('/home/foo/..'), true);
assert.strictEqual(path.posix.isAbsolute('bar/'), false);
assert.strictEqual(path.posix.isAbsolute('./baz'), false);
// Tests from VSCode:
// Absolute Paths
[
'C:/',
'C:\\',
'C:/foo',
'C:\\foo',
'z:/foo/bar.txt',
'z:\\foo\\bar.txt',
'\\\\localhost\\c$\\foo',
'/',
'/foo'
].forEach(absolutePath => {
assert.ok(path.win32.isAbsolute(absolutePath), absolutePath);
});
[
'/',
'/foo',
'/foo/bar.txt'
].forEach(absolutePath => {
assert.ok(path.posix.isAbsolute(absolutePath), absolutePath);
});
// Relative Paths
[
'',
'foo',
'foo/bar',
'./foo',
'http://foo.com/bar'
].forEach(nonAbsolutePath => {
assert.ok(!path.win32.isAbsolute(nonAbsolutePath), nonAbsolutePath);
});
[
'',
'foo',
'foo/bar',
'./foo',
'http://foo.com/bar',
'z:/foo/bar.txt',
].forEach(nonAbsolutePath => {
assert.ok(!path.posix.isAbsolute(nonAbsolutePath), nonAbsolutePath);
});
});