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

20 lines
507 B
JavaScript

'use strict';
var assert = require('assert');
module.exports = function (filepath, contents, stat) {
assert(
typeof contents === 'string' || contents instanceof Buffer,
'Expected `contents` to be a String or a Buffer'
);
var file = this.store.get(filepath);
file.isNew = file.contents === null;
file.state = 'modified';
file.contents = typeof contents === 'string' ? Buffer.from(contents) : contents;
file.stat = stat;
this.store.add(file);
return file.contents.toString();
};