当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript pfs.rename函数代码示例

本文整理汇总了TypeScript中vs/base/node/pfs.rename函数的典型用法代码示例。如果您正苦于以下问题:TypeScript rename函数的具体用法?TypeScript rename怎么用?TypeScript rename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rename函数的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('simple file operations, ignore', async () => {
		let request: IWatcherRequest = { basePath: testDir, ignored: ['**/b/**', '**/*.js', '.git/**'] };
		service.setRoots([request]);
		await wait(300);

		assert.equal(service.wacherCount, 1);

		// create various ignored files
		let file1 = path.join(bFolder, 'file1.txt'); // hidden
		await pfs.writeFile(file1, 'Hello');
		let file2 = path.join(b2Folder, 'file2.txt'); // hidden
		await pfs.writeFile(file2, 'Hello');
		let folder1 = path.join(bFolder, 'folder1'); // hidden
		await pfs.mkdirp(folder1);
		let folder2 = path.join(aFolder, 'b'); // hidden
		await pfs.mkdirp(folder2);
		let folder3 = path.join(testDir, '.git'); // hidden
		await pfs.mkdirp(folder3);
		let folder4 = path.join(testDir, '.git1');
		await pfs.mkdirp(folder4);
		let folder5 = path.join(aFolder, '.git');
		await pfs.mkdirp(folder5);
		let file3 = path.join(aFolder, 'file3.js'); // hidden
		await pfs.writeFile(file3, 'var x;');
		let file4 = path.join(aFolder, 'file4.txt');
		await pfs.writeFile(file4, 'Hello');
		await assertFileEvents(result, [{ path: file4, type: FileChangeType.ADDED }, { path: folder4, type: FileChangeType.ADDED }, { path: folder5, type: FileChangeType.ADDED }]);

		// move some files
		let movedFile1 = path.join(folder2, 'file1.txt'); // from ignored to ignored
		await pfs.rename(file1, movedFile1);
		let movedFile2 = path.join(aFolder, 'file2.txt'); // from ignored to visible
		await pfs.rename(file2, movedFile2);
		let movedFile3 = path.join(aFolder, 'file3.txt'); // from ignored file ext to visible
		await pfs.rename(file3, movedFile3);
		await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.ADDED }, { path: movedFile3, type: FileChangeType.ADDED }]);

		// delete all files
		await pfs.del(movedFile1); // hidden
		await pfs.del(movedFile2);
		await pfs.del(movedFile3);
		await pfs.del(folder1); // hidden
		await pfs.del(folder2); // hidden
		await pfs.del(folder3); // hidden
		await pfs.del(folder4);
		await pfs.del(folder5);
		await pfs.del(file4);
		await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.DELETED }, { path: movedFile3, type: FileChangeType.DELETED }, { path: file4, type: FileChangeType.DELETED }, { path: folder4, type: FileChangeType.DELETED }, { path: folder5, type: FileChangeType.DELETED }]);
	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:49,代码来源:chockidarWatcherService.test.ts


注:本文中的vs/base/node/pfs.rename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。