var async = require('async');
var request = require('request');
var sugar = require('mongoose-sugar');

var Library = require('../schemas').Library;


module.exports = function(cb) {
    var url = 'http://www.jsdelivr.com/packagesmain.php';

    request.get({
        url: url,
        json: true
    }, function(err, res, data) {
        if(err || !data || !data.package) {
            console.error('Failed to update data!', err, data);

            return cb(err);
        }

        async.each(data.package, function(library, cb) {
            sugar.getOrCreate(Library, {
                name: library.name
            }, function(err, d) {
                if(err) {
                    return cb(err);
                }

                sugar.update(Library, d._id, library, cb);
            });
        }, function(err) {
            if(err) {
                console.error(err);

                return cb(err);
            }

            console.log('Updated data');

            cb();
        });;
    })
};

@@ -345,17 +345,17 @@
 r %7C%7C
-%C2%A0
+ 
 !data %7C%7C
 %C2%A0!da
@@ -354,9 +354,9 @@
 a %7C%7C
-%C2%A0
+ 
 !dat
@@ -1003,16 +1003,17 @@
  %7D);
-;
 %0A    %7D)
+;
 %0A%7D;%0A
+%0A

Remove weird apple spaces