fis-scaffold-kernel
Advanced tools
Comparing version 0.0.21 to 0.0.22
var util = require('./util.js'); | ||
var exports = module.exports = function (option) { | ||
this.repos = option.repos || 'https://codeload.github.com/'; | ||
this.postfix = '/tar.gz/'; | ||
exports.repos = option.repos || 'https://codeload.github.com/'; | ||
exports.postfix = '/tar.gz/'; | ||
}; | ||
function downloadFromGithub(address, version, cb, progress) { | ||
util.download(exports.repos + address + exports.postfix + version, {}, cb, progress); | ||
} | ||
function downloadFromMirror(address, version, cb, progress) { | ||
var parts = address.split('/'); | ||
var ns = parts[0]; | ||
var repos = parts[1]; | ||
var folder = ns.substring(4); | ||
util.download('http://fis-cloud.bj.bcebos.com/' + folder + '/' + repos + '/' + version + '/all2.tar.gz?responseContentDisposition=attachment', null, function(error) { | ||
if (error) { | ||
console.log('Download From Mirror fail, fallback to github self.'); | ||
return downloadFromGithub(address, version, cb, progress); | ||
} | ||
return cb.apply(this, arguments); | ||
}, progress); | ||
} | ||
exports.prototype.download = function (id, cb, progress) { | ||
@@ -12,3 +35,3 @@ if (!id) { | ||
} | ||
var util = require('./util.js'); | ||
var c = id.split('@'); | ||
@@ -18,4 +41,8 @@ if (!c[1]) { | ||
} | ||
var url = this.repos + c[0] + this.postfix + c[1]; | ||
util.download(url, {}, cb, progress); | ||
}; | ||
if (c[0].indexOf('fis-components/') === 0 || c[0].indexOf('fis-scaffold/') === 0) { | ||
return downloadFromMirror(c[0], c[1], cb, progress); | ||
} | ||
downloadFromGithub(c[0], c[1], cb, progress); | ||
}; |
{ | ||
"name": "fis-scaffold-kernel", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"description": "fis-scaffold-kernel", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
26926
712