Files
bake/contrib/bake-vscode/node_modules/mem-fs-editor/lib/actions/read.js
T
2019-09-17 13:20:42 -04:00

17 lines
395 B
JavaScript

'use strict';
module.exports = function (filepath, options) {
options = options || {raw: false};
var file = this.store.get(filepath);
if (file.state === 'deleted' || file.contents === null) {
if ('defaults' in options) {
return options.defaults;
}
throw new Error(filepath + ' doesn\'t exist');
}
return options.raw ? file.contents : file.contents.toString();
};