/
sequelize
executable file
·91 lines (69 loc) · 2.22 KB
/
sequelize
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
84
85
86
87
88
89
90
91
#!/usr/bin/env node
'use strict';
var spawn = require('child_process').spawn;
var fs = require('fs');
var path = require('path');
var gulp = path.resolve(__dirname, '..', 'node_modules', 'gulp', 'bin', 'gulp.js');
var args = process.argv.slice(2);
var yargs = require('yargs');
var _ = require('lodash');
var helpers = require(path.resolve(__dirname, '..', 'lib', 'helpers'));
if (!fs.existsSync(gulp)) {
gulp = path.resolve(process.cwd(), 'node_modules', 'gulp', 'bin', 'gulp.js');
}
if (!fs.existsSync(gulp)) {
throw new Error('Unable to find the `gulp` binary');
}
if ((args[0] === '-v') || (args[0] === '-V')) {
args = ['version'];
}
// Let's load additional options from a file and add it to the gulp call
(function (optionsPath) {
var rcFile = path.resolve(process.cwd(), '.sequelizerc');
if (!optionsPath && fs.existsSync(rcFile)) {
optionsPath = rcFile;
}
if (optionsPath) {
var options = require(optionsPath);
Object.keys(options).forEach(function (optionKey) {
var value = options[optionKey];
if (optionKey.indexOf('--') !== 0) {
optionKey = '--' + optionKey;
}
args = args.concat([optionKey, value]);
});
}
})(yargs.argv.optionsPath);
args = args.concat([
'--gulpfile', path.resolve(__dirname, '..', 'lib', 'gulpfile.js'),
'--cwd', process.cwd()
]);
args.unshift(gulp);
// Add harmony support
[ '--harmony-scoping', '--harmony-modules', '--harmony-proxies',
'--harmony-generators', '--harmony-numeric-literals', '--harmony-strings',
'--harmony-arrays', '--harmony-arrow-functions', '--harmony'
].forEach(function (harmonyFlag) {
if (_.includes(args, harmonyFlag)) {
args = _.without(args, harmonyFlag);
args.unshift(harmonyFlag);
}
});
var call = spawn(process.argv[0], args);
helpers.view.teaser();
call.stdout.on('data', function (data) {
var lines = data.toString().split('\n');
lines = lines.filter(function (line) {
return !line.match(/\[\d{2}:\d{2}:\d{2}\]/);
});
var result = lines
.join('\n')
.replace('gulp [task]', 'sequelize [task]');
process.stdout.write(result);
});
call.stderr.on('data', function (data) {
process.stderr.write(data);
});
call.on('exit', function (code) {
process.exit(code);
});