當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。