/**
 * Create aliases.
 * @function task.worker._createAliases
 * @param {object} data - Alias data.
 * @param {function} callback - Callback when done.
 * @author Taka Okunishi
 * @protected
 * @ignore
 */
var path = require('path'),
    debug = require('./_debug'),
    file = require('../../lib/file'),
    relativeSymlink = file.relativeSymlink;

module.exports = function (data, callback) {
    require('async').series(
        data.map(function (data) {
            return function (callback) {
                var from = path.resolve(data.from),
                    to = path.resolve(data.to);
                relativeSymlink(from, to, function (err) {
                    if (!err) {
                        debug.didCreateLink(to, from);
                    }
                    callback(err);
                });
            };
        }),
        function (err) {
            callback(err);
        }
    );
};