-
Notifications
You must be signed in to change notification settings - Fork 1
/
bin.js
67 lines (56 loc) · 1.64 KB
/
bin.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
62
63
64
65
66
67
#!/usr/bin/env node
'use strict';
require('colors');
var api = require('./index');
var path = require('path');
var _ = require('underscore');
var data = {};
var infoDefault = {};
api.intro()
.then(function (intro) {
console.log(intro);
// Get defaults
api.command('git config --get user.name')
.then(function (name) {
infoDefault.name = name;
return api.command('git config --get user.email');
})
.then(function (email) {
infoDefault.email = email;
})
.catch(function (err) {
infoDefault.name = null;
infoDefault.email = null;
console.error('Warning: '.yellow + 'You should install git!');
});
return api.promptLicense();
})
.then(function (answer) {
data.license = answer.license;
return api.promptInfo(answer.license, infoDefault);
})
.then(function (info) {
data.name = info.name;
data.email = info.email;
data.software = info.software;
data.description = info.description;
data.years = info.years;
data.file = info.file;
return api.write(data);
})
.then(function (license) {
if (license.split('\n').length < 35) {
console.log('\n--------\n'.grey);
console.log(license);
console.log('--------\n'.grey);
}
var warns = [ 'LGPL-2.1' ];
if (_.contains(warns, data.license)) {
console.error('Warning: '.yellow + 'More informations are required by\
the license. You should check them at the bottom of the file.');
}
console.log('License saved to: %s', path.resolve(data.file).green);
})
.catch(function (err) {
console.log('Error: '.red + err.message);
});