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


TypeScript paths.join函數代碼示例

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


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

示例1: test

	test('Workspace ensures absolute and unique roots', () => {

		// Unique
		let roots = [URI.file('/some/path'), URI.file('/some/path')];
		let ws = new Workspace('id', 'name', roots, URI.file('/config'));

		assert.equal(ws.roots.length, 1);

		// Absolute
		let config = URI.file('/someFolder/workspace.code-workspace');
		roots = [URI.parse('./some/path'), URI.parse('some/other/path')];
		ws = new Workspace('id', 'name', roots, config);

		assert.equal(ws.roots.length, 2);
		assert.equal(ws.roots[0].fsPath, join(dirname(config.fsPath), roots[0].fsPath));
		assert.equal(ws.roots[1].fsPath, join(dirname(config.fsPath), roots[1].fsPath));

		// Absolute (from root)
		config = URI.file('/workspace.code-workspace');
		roots = [URI.parse('./some/path'), URI.parse('some/other/path')];
		ws = new Workspace('id', 'name', roots, config);

		assert.equal(ws.roots.length, 2);
		assert.equal(ws.roots[0].fsPath, join(dirname(config.fsPath), roots[0].fsPath));
		assert.equal(ws.roots[1].fsPath, join(dirname(config.fsPath), roots[1].fsPath));
	});
開發者ID:pavelfeldman,項目名稱:vscode,代碼行數:26,代碼來源:workspace.test.ts

示例2: test

	test('File Changes Event', function () {
		let changes = [
			{ resource: URI.file(Paths.join('C:\\', '/foo/updated.txt')), type: 0 },
			{ resource: URI.file(Paths.join('C:\\', '/foo/otherupdated.txt')), type: 0 },
			{ resource: URI.file(Paths.join('C:\\', '/added.txt')), type: 1 },
			{ resource: URI.file(Paths.join('C:\\', '/bar/deleted.txt')), type: 2 },
			{ resource: URI.file(Paths.join('C:\\', '/bar/folder')), type: 2 }
		];

		let r1 = new FileChangesEvent(changes);

		assert(!r1.contains(toResource('/foo'), 0));
		assert(r1.contains(toResource('/foo/updated.txt'), 0));
		assert(!r1.contains(toResource('/foo/updated.txt'), 1));
		assert(!r1.contains(toResource('/foo/updated.txt'), 2));

		assert(r1.contains(toResource('/bar/folder'), 2));
		assert(r1.contains(toResource('/bar/folder/somefile'), 2));
		assert(r1.contains(toResource('/bar/folder/somefile/test.txt'), 2));
		assert(!r1.contains(toResource('/bar/folder2/somefile'), 2));

		assert.strictEqual(5, r1.changes.length);
		assert.strictEqual(1, r1.getAdded().length);
		assert.strictEqual(true, r1.gotAdded());
		assert.strictEqual(2, r1.getUpdated().length);
		assert.strictEqual(true, r1.gotUpdated());
		assert.strictEqual(2, r1.getDeleted().length);
		assert.strictEqual(true, r1.gotDeleted());
	});
開發者ID:1Hgm,項目名稱:vscode,代碼行數:29,代碼來源:events.test.ts

示例3: test

	test('FileChangesEvent', () => {
		let changes = [
			{ resource: URI.file(join('C:\\', '/foo/updated.txt')), type: FileChangeType.UPDATED },
			{ resource: URI.file(join('C:\\', '/foo/otherupdated.txt')), type: FileChangeType.UPDATED },
			{ resource: URI.file(join('C:\\', '/added.txt')), type: FileChangeType.ADDED },
			{ resource: URI.file(join('C:\\', '/bar/deleted.txt')), type: FileChangeType.DELETED },
			{ resource: URI.file(join('C:\\', '/bar/folder')), type: FileChangeType.DELETED }
		];

		let r1 = new FileChangesEvent(changes);

		assert(!r1.contains(toResource('/foo'), FileChangeType.UPDATED));
		assert(r1.contains(toResource('/foo/updated.txt'), FileChangeType.UPDATED));
		assert(!r1.contains(toResource('/foo/updated.txt'), FileChangeType.ADDED));
		assert(!r1.contains(toResource('/foo/updated.txt'), FileChangeType.DELETED));

		assert(r1.contains(toResource('/bar/folder'), FileChangeType.DELETED));
		assert(r1.contains(toResource('/bar/folder/somefile'), FileChangeType.DELETED));
		assert(r1.contains(toResource('/bar/folder/somefile/test.txt'), FileChangeType.DELETED));
		assert(!r1.contains(toResource('/bar/folder2/somefile'), FileChangeType.DELETED));

		assert.strictEqual(5, r1.changes.length);
		assert.strictEqual(1, r1.getAdded().length);
		assert.strictEqual(true, r1.gotAdded());
		assert.strictEqual(2, r1.getUpdated().length);
		assert.strictEqual(true, r1.gotUpdated());
		assert.strictEqual(2, r1.getDeleted().length);
		assert.strictEqual(true, r1.gotDeleted());
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:29,代碼來源:files.test.ts

示例4: handleCommand

	function handleCommand(userFriendlyCommand: schema.IUserFriendlyCommand , extension: IExtensionPointUser<any>) {

		if (!schema.isValidCommand(userFriendlyCommand, extension.collector)) {
			return;
		}

		let {icon, category, title, command} = userFriendlyCommand;
		let iconClass: string;
		if (icon) {
			iconClass = ids.nextId();
			if (typeof icon === 'string') {
				const path = join(extension.description.extensionFolderPath, icon);
				createCSSRule(`.icon.${iconClass}`, `background-image: url("${path}")`);
			} else {
				const light = join(extension.description.extensionFolderPath, icon.light);
				const dark = join(extension.description.extensionFolderPath, icon.dark);
				createCSSRule(`.icon.${iconClass}`, `background-image: url("${light}")`);
				createCSSRule(`.vs-dark .icon.${iconClass}, hc-black .icon.${iconClass}`, `background-image: url("${dark}")`);
			}
		}

		if (MenuRegistry.addCommand({ id: command, title, category, iconClass })) {
			extension.collector.info(localize('dup', "Command `{0}` appears multiple times in the `commands` section.", userFriendlyCommand.command));
		}
	}
開發者ID:baltth,項目名稱:vscode,代碼行數:25,代碼來源:menusExtensionPoint.ts

示例5: test

	test('Merge Local with Disk', function () {
		const d = new Date().toUTCString();

		const merge1 = new ExplorerItem(URI.file(join('C:\\', '/path/to')), undefined, false, true, 'to', Date.now(), d);
		const merge2 = new ExplorerItem(URI.file(join('C:\\', '/path/to')), undefined, false, true, 'to', Date.now(), new Date(0).toUTCString());

		// Merge Properties
		ExplorerItem.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.mtime, merge2.mtime);

		// Merge Child when isDirectoryResolved=false is a no-op
		merge2.addChild(new ExplorerItem(URI.file(join('C:\\', '/path/to/foo.html')), undefined, false, true, 'foo.html', Date.now(), d));
		ExplorerItem.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.getChildrenArray().length, 0);

		// Merge Child with isDirectoryResolved=true
		const child = new ExplorerItem(URI.file(join('C:\\', '/path/to/foo.html')), undefined, false, true, 'foo.html', Date.now(), d);
		merge2.removeChild(child);
		merge2.addChild(child);
		merge2.isDirectoryResolved = true;
		ExplorerItem.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.getChildrenArray().length, 1);
		assert.strictEqual(merge1.getChild('foo.html').name, 'foo.html');
		assert.deepEqual(merge1.getChild('foo.html').parent, merge1, 'Check parent');

		// Verify that merge does not replace existing children, but updates properties in that case
		const existingChild = merge1.getChild('foo.html');
		ExplorerItem.mergeLocalWithDisk(merge2, merge1);
		assert.ok(existingChild === merge1.getChild(existingChild.name));
	});
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:30,代碼來源:explorerModel.test.ts

示例6: test

	test('Merge Local with Disk', function () {
		const d = new Date().toUTCString();

		const merge1 = new FileStat(URI.file(join('C:\\', '/path/to')), true, false, 'to', void 0, 8096, d);
		const merge2 = new FileStat(URI.file(join('C:\\', '/path/to')), true, false, 'to', void 0, 16000, new Date(0).toUTCString());

		// Merge Properties
		FileStat.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.mtime, merge2.mtime);

		// Merge Child when isDirectoryResolved=false is a no-op
		merge2.addChild(new FileStat(URI.file(join('C:\\', '/path/to/foo.html')), true, false, 'foo.html', void 0, 8096, d));
		FileStat.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.children.length, 0);

		// Merge Child with isDirectoryResolved=true
		const child = new FileStat(URI.file(join('C:\\', '/path/to/foo.html')), true, false, 'foo.html', void 0, 8096, d);
		merge2.removeChild(child);
		merge2.addChild(child);
		merge2.isDirectoryResolved = true;
		FileStat.mergeLocalWithDisk(merge2, merge1);
		assert.strictEqual(merge1.children.length, 1);
		assert.strictEqual(merge1.children[0].name, 'foo.html');
		assert.deepEqual(merge1.children[0].parent, merge1, 'Check parent');

		// Verify that merge does not replace existing children, but updates properties in that case
		const existingChild = merge1.children[0];
		FileStat.mergeLocalWithDisk(merge2, merge1);
		assert.ok(existingChild === merge1.children[0]);
	});
開發者ID:GYGit,項目名稱:vscode,代碼行數:30,代碼來源:explorerViewModel.test.ts

示例7: toResource

function toResource(path) {
	if (isWindows) {
		return URI.file(join('C:\\', path));
	} else {
		return URI.file(join('/home/john', path));
	}
}
開發者ID:VishalMadhvani,項目名稱:vscode,代碼行數:7,代碼來源:explorerModel.test.ts

示例8: joinPath

export function joinPath(resource: URI, pathFragment: string): URI {
	let joinedPath: string;
	if (resource.scheme === Schemas.file) {
		joinedPath = URI.file(paths.join(fsPath(resource), pathFragment)).path;
	} else {
		joinedPath = paths.join(resource.path, pathFragment);
	}
	return resource.with({
		path: joinedPath
	});
}
開發者ID:donaldpipowitch,項目名稱:vscode,代碼行數:11,代碼來源:resources.ts

示例9:

				toResource: (folderRelativePath: string): URI => {
					if (typeof folderRelativePath === 'string') {
						return URI.file(paths.join(folderPath, folderRelativePath));
					}

					return null;
				}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:7,代碼來源:outputLinkComputer.ts

示例10: getCwd

export function getCwd(shell: IShellLaunchConfig, root: Uri, configHelper: ITerminalConfigHelper): string {
	if (shell.cwd) {
		return shell.cwd;
	}

	let cwd: string;

	// TODO: Handle non-existent customCwd
	if (!shell.ignoreConfigurationCwd) {
		// Evaluate custom cwd first
		const customCwd = configHelper.config.cwd;
		if (customCwd) {
			if (paths.isAbsolute(customCwd)) {
				cwd = customCwd;
			} else if (root) {
				cwd = paths.normalize(paths.join(root.fsPath, customCwd));
			}
		}
	}

	// If there was no custom cwd or it was relative with no workspace
	if (!cwd) {
		cwd = root ? root.fsPath : os.homedir();
	}

	return _sanitizeCwd(cwd);
}
開發者ID:ramesius,項目名稱:vscode,代碼行數:27,代碼來源:terminalEnvironment.ts


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