mirror of
https://github.com/kennethreitz/bake.git
synced 2026-06-05 23:00:17 +00:00
20 lines
507 B
JavaScript
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();
|
|
};
|