本文整理匯總了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));
});