Sha256: 76f08f1c23c79c7fb49590af9ca70eff6c9e45264b1f4a21784a226ded5b60e6

Contents?: true

Size: 1.8 KB

Versions: 16

Compression:

Stored size: 1.8 KB

Contents

#!/usr/bin/env node

var fs = require('fs'),
    httpGet = require('http').get,
    httpsGet = require('https').get,
    parseURL = require('url').parse;

var FILES = {
  "ember-1.0.1": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.1/ember.js",
  "ember-release": "http://builds.emberjs.com/release/ember.js",
  "ember-beta": "http://builds.emberjs.com/beta/ember.js",
  "ember-canary": "http://builds.emberjs.com/canary/ember.js",

  "jquery-1.9.1": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js",
  "jquery-1.11.0": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js",
  "jquery-2.0.3": "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js",

  "handlebars-1.1.0": "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.1.0/handlebars.js",
  "handlebars-1.3.0": "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.js"
};

function fetchAll() {
  for (var library in FILES) {
    if (FILES.hasOwnProperty(library)) {
      fetchIfUnfetched(library);
    }
  }
}

function fetchIfUnfetched(library) {
  var dest = destination(library);
  if (fs.existsSync(dest)) { return; }

  curl(FILES[library], function (body) {
    fs.writeFileSync(dest, body);
    console.info('Wrote ' + dest);
  });
}

function destination(library) {
  return 'vendor/' + library + '.js';
}

function get(urlOptions, callback) {
  var fn = urlOptions.protocol === 'https:' ? httpsGet : httpGet;
  return fn(urlOptions, callback);
}

function curl(url, callback) {
  var urlOptions = parseURL(url);
  get(urlOptions, function(res) {
    if (res.statusCode >= 400) {
      throw new Error('Error fetching ' + url);
    }

    var buf = '';
    res.on('data', function (chunk) {
      buf += chunk;
    });
    res.on('end', function () {
      callback(buf);
    });
  });
}

fetchAll();

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dune-dashboard-1.1.5 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.1.4 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.1.3 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.1.2 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.1.1 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.1.0 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.9 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.8 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.7 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.6 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.5 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.4 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.3 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.2 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.1 vendor/assets/components/ember-i18n/script/fetch_vendor.js
dune-dashboard-1.0.0 vendor/assets/components/ember-i18n/script/fetch_vendor.js