/**
 * Append file contents to another file.
 * @function lib.file.appendFile
 * @param {string} src - File path to append from.
 * @param {string} dest - File path to append to.
 * @author Taka Okunishi
 *
 */
var fs = require('fs');
module.exports = function (src, dest, callback) {
    var readStream = fs.createReadStream(src),
        writeStream = fs.createWriteStream(dest, {
            flags: 'a'
        });
    readStream.on('error', function (err) {
        callback && callback(err);
        callback = null;
    });
    writeStream.on('error', function (err) {
        callback && callback(err);
        callback = null;
    });
    writeStream.on('close', function () {
        callback && callback(null);
    });
    readStream.pipe(writeStream);
};