You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
497 B
18 lines
497 B
const 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',
|
|
);
|
|
|
|
const 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();
|
|
};
|