2016-02-29 10:45:19 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var fs = require('fs');
|
2017-02-15 21:25:32 +00:00
|
|
|
var pify = require('pify');
|
2016-02-29 10:45:19 +00:00
|
|
|
|
2017-02-15 21:25:32 +00:00
|
|
|
function read(filePath) {
|
|
|
|
return pify(fs.readFile)(filePath, 'utf8');
|
2016-02-29 10:45:19 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 21:25:32 +00:00
|
|
|
function write(filePath, content) {
|
|
|
|
return pify(fs.writeFile)(filePath, content);
|
2016-02-29 10:45:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-21 22:53:02 +00:00
|
|
|
function injectContentBetween(lines, content, startIndex, endIndex) {
|
|
|
|
return [].concat(
|
|
|
|
lines.slice(0, startIndex),
|
|
|
|
content,
|
|
|
|
lines.slice(endIndex)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-02-29 10:45:19 +00:00
|
|
|
module.exports = {
|
|
|
|
read: read,
|
2016-03-21 22:53:02 +00:00
|
|
|
write: write,
|
|
|
|
injectContentBetween: injectContentBetween
|
2016-03-06 23:20:24 +00:00
|
|
|
};
|