'use strict';

var through = require('through2');

module.exports = function (text) {
    var defaultText = '/* --------------------------------------------------------------------- *\\\n'
                    + '|  This code was auto-generated by a tool.                                |\n'
                    + '|                                                                         |\n'
                    + '|  Changes to this file may cause incorrect behavior and will be lost if  |\n'
                    + '|  the code is regenerated.                                               |\n'
                    + '\\* --------------------------------------------------------------------- */\n\n';
    text = text || defaultText;

    var transform = function (file, enc, cb) {
        if (file.isNull()) {
            this.push(file);
            return cb();
        }

        var contents = file.contents.toString();
        file.contents = new Buffer(text + contents);
        this.push(file);
        cb();
    };

    return through.obj(transform);
};
