Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created August 14, 2015 17:32
Show Gist options
  • Save AlexFrazer/32dc89758d71b60aa8ee to your computer and use it in GitHub Desktop.
Save AlexFrazer/32dc89758d71b60aa8ee to your computer and use it in GitHub Desktop.
#!/usr/bin/env node --harmony
'use strict';
require('shelljs/make');
require('shelljs/global');
let os = require('os');
let path = require('path');
let wget = require('./wget');
target.all = function () {
console.log(`Building Application\n\tOS: ${os.platform()}\n\t${os.arch()}`);
target.setup();
target.build();
}
target.setup = function () {
console.log('====>\tDownloading dependencies');
let dependencies = require('./dependencies')(); // generates the dependency array
let target = path.join(__dirname, 'target');
mkdir(target);
cd(target);
Promise.each(dependencies, function (dep) {
return wget(dep);
}).catch(function (error) {
console.warn('ERROR': error);
exit(error.code);
});
}
let Promise = require('bluebird');
let wget = require('wget-improved');
let utils = require('./utilities');
module.exports = function (dep) {
var deferred = Promise.pending();
wget.download(dep.url, dep.filepath)
.on('end', function () {
utils.extract(dep.filepath);
deffered.resolve();
})
.on('error', deferred.reject)
.on('progress', function (progress) {
// add to my progress bar here
// this isn't a major concern right now
});
return deferred;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment