1 | 'use strict';
|
2 |
|
3 | var assert = require('assert');
|
4 |
|
5 | module.exports = function (filepath, contents, stat) {
|
6 | assert(
|
7 | typeof contents === 'string' || contents instanceof Buffer,
|
8 | 'Expected `contents` to be a String or a Buffer'
|
9 | );
|
10 |
|
11 | var file = this.store.get(filepath);
|
12 | file.isNew = file.contents === null;
|
13 | file.state = 'modified';
|
14 | file.contents = typeof contents === 'string' ? Buffer.from(contents) : contents;
|
15 | file.stat = stat;
|
16 | this.store.add(file);
|
17 |
|
18 | return file.contents.toString();
|
19 | };
|