forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsails-console.js
64 lines (49 loc) · 1.18 KB
/
sails-console.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
#!/usr/bin/env node
/**
* Module dependencies
*/
var Sails = require('../lib/app')
, path = require('path')
, _ = require('lodash')
, rconf = require('../lib/configuration/rc')
, captains = require('captains-log')
, REPL = require('repl');
require('colors');
/**
* `sails console`
*
* Enter the interactive console (aka REPL) for the app
* in our working directory.
*/
module.exports = function () {
var log = captains(rconf.log);
console.log();
log.info('Starting app in interactive mode...'.debug);
console.log();
// Now load up sails for real
var sails = Sails();
sails.lift(_.merge({}, rconf, {
// Silence annoying warning
// (if you're in the REPL, you already know.)
express: {
silenceMultipartWarning: true
},
// Disable ASCII ship to keep from dirtying things up
log: {
noShip: true
}
}), function(err) {
if (err) return Err.fatal.failedToLoadSails(err);
log.info('Welcome to the Sails console.');
log.info(('( to exit, type '+'<CTRL>+<C>'+' )').grey);
console.log();
var repl = REPL.start('sails> ');
repl.on('exit', function(err) {
if (err) {
log.error(err);
process.exit(1);
}
process.exit(0);
});
});
};