本文整理汇总了TypeScript中vs/workbench/services/files/node/fileService.FileService.resolveContent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FileService.resolveContent方法的具体用法?TypeScript FileService.resolveContent怎么用?TypeScript FileService.resolveContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/workbench/services/files/node/fileService.FileService
的用法示例。
在下文中一共展示了FileService.resolveContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('resolveContent - FILE_IS_BINARY', function () {
const resource = uri.file(path.join(testDir, 'binary.txt'));
return service.resolveContent(resource, { acceptTextOnly: true }).then(null, (e: FileOperationError) => {
assert.equal(e.fileOperationResult, FileOperationResult.FILE_IS_BINARY);
return service.resolveContent(uri.file(path.join(testDir, 'small.txt')), { acceptTextOnly: true }).then(r => {
assert.equal(r.name, 'small.txt');
});
});
});
示例2:
return encodingLib.detectEncodingByBOM(c.resource.fsPath).then((enc) => {
assert.equal(enc, encodingLib.UTF16le);
return service.resolveContent(resource).then(c => {
assert.equal(c.encoding, encoding);
model.dispose();
done();
});
});
示例3:
_service.resolveContent(uri.file(path.join(testDir, 'index.html'))).done(c => {
assert.equal(c.encoding, 'windows1252');
return _service.resolveContent(uri.file(path.join(testDir, 'deep', 'conway.js'))).done(c => {
assert.equal(c.encoding, 'utf16le');
// teardown
_service.dispose();
done();
});
});
示例4: test
test('resolveContent - FILE_NOT_MODIFIED_SINCE', function (done: () => void) {
let resource = uri.file(path.join(testDir, 'index.html'));
service.resolveContent(resource).done(c => {
return service.resolveContent(resource, { etag: c.etag }).then(null, (e: IFileOperationResult) => {
assert.equal(e.fileOperationResult, FileOperationResult.FILE_NOT_MODIFIED_SINCE);
done();
});
}, error => onError(error, done));
});
示例5: test
test('updateContent (large file)', function (done: () => void) {
const resource = uri.file(path.join(testDir, 'lorem.txt'));
service.resolveContent(resource).done(c => {
const newValue = c.value + c.value;
c.value = newValue;
return service.updateContent(c.resource, c.value).then(c => {
assert.equal(fs.readFileSync(resource.fsPath), newValue);
done();
});
}, error => onError(error, done));
});