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.
20 lines
442 B
20 lines
442 B
const extend = require('deep-extend');
|
|
const { EOL } = require('os');
|
|
|
|
module.exports = function append(to, contents, options) {
|
|
const newOptions = extend(
|
|
{
|
|
trimEnd: true,
|
|
separator: EOL,
|
|
},
|
|
options || {},
|
|
);
|
|
|
|
let currentContents = this.read(to);
|
|
if (newOptions.trimEnd) {
|
|
currentContents = currentContents.replace(/\s+$/, '');
|
|
}
|
|
|
|
this.write(to, currentContents + newOptions.separator + contents);
|
|
};
|