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


TypeScript pfs.copy函數代碼示例

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


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

示例1: test

	test('simple file operations, single root, no ignore', async () => {
		let request: IWatcherRequest = { basePath: testDir, ignored: [] };
		service.setRoots([request]);
		await wait(300);

		assert.equal(service.wacherCount, 1);

		// create a file
		let testFilePath = path.join(testDir, 'file.txt');
		await pfs.writeFile(testFilePath, '');
		await assertFileEvents(result, [{ path: testFilePath, type: FileChangeType.ADDED }]);

		// modify a file
		await pfs.writeFile(testFilePath, 'Hello');
		await assertFileEvents(result, [{ path: testFilePath, type: FileChangeType.UPDATED }]);

		// create a folder
		let testFolderPath = path.join(testDir, 'newFolder');
		await pfs.mkdirp(testFolderPath);
		// copy a file
		let copiedFilePath = path.join(testFolderPath, 'file2.txt');
		await pfs.copy(testFilePath, copiedFilePath);
		await assertFileEvents(result, [{ path: copiedFilePath, type: FileChangeType.ADDED }, { path: testFolderPath, type: FileChangeType.ADDED }]);

		// delete a file
		await pfs.del(copiedFilePath);
		let renamedFilePath = path.join(testFolderPath, 'file3.txt');
		// move a file
		await pfs.rename(testFilePath, renamedFilePath);
		await assertFileEvents(result, [{ path: copiedFilePath, type: FileChangeType.DELETED }, { path: testFilePath, type: FileChangeType.DELETED }, { path: renamedFilePath, type: FileChangeType.ADDED }]);

		// delete a folder
		await pfs.del(testFolderPath);
		await assertFileEvents(result, [{ path: testFolderPath, type: FileChangeType.DELETED }, { path: renamedFilePath, type: FileChangeType.DELETED }]);
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:35,代碼來源:chockidarWatcherService.test.ts

示例2: setup

	setup(function () {
		const id = uuid.generateUuid();
		testDir = path.join(parentDir, id);
		const sourceDir = require.toUrl('./fixtures/service');

		return pfs.copy(sourceDir, testDir).then(() => {
			service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
		});
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:9,代碼來源:fileService.test.ts

示例3: setup

	setup(async () => {
		service = new FileService2(new NullLogService());
		disposables.push(service);

		fileProvider = new TestDiskFileSystemProvider();
		service.registerProvider(Schemas.file, fileProvider);

		testProvider = new TestDiskFileSystemProvider();
		service.registerProvider(testSchema, testProvider);

		const id = generateUuid();
		testDir = join(parentDir, id);
		const sourceDir = getPathFromAmdModule(require, './fixtures/service');

		await copy(sourceDir, testDir);
	});
開發者ID:joelday,項目名稱:vscode,代碼行數:16,代碼來源:diskFileService.test.ts

示例4: test

	test('options - encoding override (extension)', function () {

		// setup
		const _id = uuid.generateUuid();
		const _testDir = path.join(parentDir, _id);
		const _sourceDir = require.toUrl('./fixtures/service');

		return pfs.copy(_sourceDir, _testDir).then(() => {
			const encodingOverride: IEncodingOverride[] = [];
			encodingOverride.push({
				extension: 'js',
				encoding: 'utf16le'
			});

			const configurationService = new TestConfigurationService();
			configurationService.setUserConfiguration('files', { encoding: 'windows1252' });

			const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);

			const _service = new FileService(
				new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
				TestEnvironmentService,
				textResourceConfigurationService,
				configurationService,
				new TestLifecycleService(),
				new TestStorageService(),
				new TestNotificationService(),
				{
					encodingOverride,
					disableWatcher: true
				});

			return _service.resolveContent(uri.file(path.join(testDir, 'index.html'))).then(c => {
				assert.equal(c.encoding, 'windows1252');

				return _service.resolveContent(uri.file(path.join(testDir, 'deep', 'conway.js'))).then(c => {
					assert.equal(c.encoding, 'utf16le');

					// teardown
					_service.dispose();
				});
			});
		});
	});
開發者ID:liunian,項目名稱:vscode,代碼行數:44,代碼來源:fileService.test.ts


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