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


TypeScript FileService.updateContent方法代码示例

本文整理汇总了TypeScript中vs/workbench/services/files/node/fileService.FileService.updateContent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FileService.updateContent方法的具体用法?TypeScript FileService.updateContent怎么用?TypeScript FileService.updateContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/workbench/services/files/node/fileService.FileService的用法示例。


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

示例1:

		return service.resolveContent(resource).then(c => {
			fs.writeFileSync(resource.fsPath, 'Updates Incoming!');

			return service.updateContent(resource, c.value, { etag: c.etag, mtime: c.mtime - 1000 }).then(null, (e: FileOperationError) => {
				assert.equal(e.fileOperationResult, FileOperationResult.FILE_MODIFIED_SINCE);
			});
		});
开发者ID:sameer-coder,项目名称:vscode,代码行数:7,代码来源:fileService.test.ts

示例2:

					fs.readFile(resource.fsPath, (error, data) => {
						assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);

						// Update content: PRESERVE BOM when using UTF-8
						_service.updateContent(resource, 'Please stay Bom', { encoding: encodingLib.UTF8 }).done(() => {
							fs.readFile(resource.fsPath, (error, data) => {
								assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);

								// Update content: REMOVE BOM
								_service.updateContent(resource, 'Go away Bom', { encoding: encodingLib.UTF8, overwriteEncoding: true }).done(() => {
									fs.readFile(resource.fsPath, (error, data) => {
										assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);

										// Update content: BOM comes not back
										_service.updateContent(resource, 'Do not come back Bom', { encoding: encodingLib.UTF8 }).done(() => {
											fs.readFile(resource.fsPath, (error, data) => {
												assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);

												_service.dispose();
												done();
											});
										});
									});
								});
							});
						});
					});
开发者ID:elemongw,项目名称:vscode,代码行数:27,代码来源:fileService.test.ts

示例3: FileService

							fs.readFile(resource.fsPath, (error, data) => {
								assert.equal(encoding.detectEncodingByBOMFromBuffer(data, 512), encoding.UTF8);

								_service.dispose();
								_service = new FileService(_testDir, null, {
									bom: BOMConfiguration.REMOVE,
									disableWatcher: true
								});

								// Update content: BOM => REMOVE
								_service.updateContent(resource, 'Hello Bom').done(() => {
									fs.readFile(resource.fsPath, (error, data) => {
										assert.equal(encoding.detectEncodingByBOMFromBuffer(data, 512), null);

										_service.dispose();
										_service = new FileService(_testDir, null, {
											bom: BOMConfiguration.PRESERVE,
											disableWatcher: true
										});

										// Update content: BOM => PRESERVE
										_service.updateContent(resource, 'Hello Bom').done(() => {
											fs.readFile(resource.fsPath, (error, data) => {
												assert.equal(encoding.detectEncodingByBOMFromBuffer(data, 512), null);

												_service.dispose();
												done();
											});
										});
									});
								});
							});
开发者ID:LiuYunbao,项目名称:vscode,代码行数:32,代码来源:fileService.test.ts

示例4:

		service.resolveContent(resource).done(c => {
			c.charset = charset;

			return service.updateContent(c.resource, c.value, { charset: charset }).then(c => {
				return service.resolveContent(resource).then(c => {
					assert.equal(c.charset, charset);

					done();
				});
			});
		});
开发者ID:gaoxiaojun,项目名称:vscode,代码行数:11,代码来源:service.test.ts


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