-
-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathview-helper.js
More file actions
83 lines (67 loc) · 1.79 KB
/
view-helper.js
File metadata and controls
83 lines (67 loc) · 1.79 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import colors from 'picocolors';
import _ from 'lodash';
import helpers from './index';
import getYArgs from '../core/yargs';
import process from 'process';
const args = getYArgs().argv;
module.exports = {
teaser() {
const versions = [
'Node: ' + helpers.version.getNodeVersion(),
'CLI: ' + helpers.version.getCliVersion(),
'ORM: ' + helpers.version.getOrmVersion(),
];
this.log();
this.log(colors.underline('Sequelize CLI [' + versions.join(', ') + ']'));
this.log();
},
log() {
console.log.apply(this, arguments);
},
error(error) {
let message = error;
const extraMessages = [];
if (error instanceof Error) {
message = !args.debug ? error.message : error.stack;
}
if (args.debug && error.original) {
extraMessages.push(error.original.message);
}
this.log();
console.error(`${colors.red('ERROR:')} ${message}`);
if (error.original && error.original.detail) {
console.error(`${colors.red('ERROR DETAIL:')} ${error.original.detail}`);
}
extraMessages.forEach((message) =>
console.error(`${colors.red('EXTRA MESSAGE:')} ${message}`)
);
this.log();
process.exit(1);
},
warn(message) {
this.log(`${colors.yellow('WARNING:')} ${message}`);
},
notifyAboutExistingFile(file) {
this.error(
'The file ' +
colors.blueBright(file) +
' already exists. ' +
'Run command with --force to overwrite it.'
);
},
pad(s, smth) {
let margin = smth;
if (_.isObject(margin)) {
margin = Object.keys(margin);
}
if (Array.isArray(margin)) {
margin = Math.max.apply(
null,
margin.map((o) => {
return o.length;
})
);
}
return s + new Array(margin - s.length + 1).join(' ');
},
};