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


TypeScript path.posix類代碼示例

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


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

示例1: test

	test('copyFile - same file should throw', async () => {
		const source = await service.resolveFile(URI.file(join(testDir, 'index.html')));
		const targetParent = URI.file(dirname(source.resource.fsPath));
		const target = targetParent.with({ path: posix.join(targetParent.path, posix.basename(source.resource.path)) });

		try {
			await service.copyFile(source.resource, target, true);
		} catch (error) {
			assert.ok(error);
		}
	});
開發者ID:joelday,項目名稱:vscode,代碼行數:11,代碼來源:diskFileService.test.ts

示例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}`);
			}
		}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:7,代碼來源:path.test.ts

示例3:

		].forEach(nonAbsolutePath => {
			assert.ok(!path.posix.isAbsolute(nonAbsolutePath), nonAbsolutePath);
		});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:3,代碼來源:path.test.ts

示例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);
		});
	});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:74,代碼來源:path.test.ts


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