• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript paths.join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript performance.mark函数代码示例发布时间:2022-05-25
下一篇:
TypeScript paths.isValidBasename函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap