This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
61 lines (49 loc) · 1.66 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var dependencies = require(process.cwd() + '/package.json').jspm.dependencies,
dependencyNames = Object.getOwnPropertyNames(dependencies),
jspm = require('jspm/api');
jspm.setPackagePath(process.cwd());
function installNextDependency () {
if (!dependencyNames || 0 === dependencyNames.length) {
return console.log('> Finished.');
}
var dependencyName = dependencyNames.pop(),
depencyInstallPath = dependencies[dependencyName].split('@')[0];
if (!dependencyName.match(/(^aurelia\-|.*?\/aurelia\-.*?$)/)) {
return installNextDependency();
}
notifyOnProgress(dependencyName);
jspm.install(dependencyName, {summary: true})
.then(function () {
notifyOnProgress(dependencyName, true);
installNextDependency();
})
.catch(function (error) {
jspm.install(dependencyName, depencyInstallPath, {summary: true})
.then(function () {
notifyOnProgress(dependencyName, true);
installNextDependency();
})
.catch(function (error) {
notifyOnProgress(dependencyName, error.toString());
installNextDependency();
});
});
}
function notifyOnProgress (dependency, success) {
var message = '- ' + dependency + ': ';
process.stdout.clearLine();
process.stdout.cursorTo(0);
if (typeof success === 'undefined') {
message += 'Installing...';
} else if (true === success) {
message += 'Success!';
} else {
message += 'Failed! Message: ' + success.toString();
}
process.stdout.write(message);
if (true === success) {
process.stdout.write('\n');
}
}
console.log('> Starting update.');
module.exports = installNextDependency;