本文整理汇总了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 }]);
});
示例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 });
});
});
示例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);
});
示例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();
});
});
});
});