forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsails-debug.js
46 lines (33 loc) · 1.1 KB
/
sails-debug.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
#!/usr/bin/env node
/**
* Module dependencies
*/
var Sails = require('../lib/app')
, path = require('path')
, Womb = require('child_process')
, captains = require('captains-log');
/*
# This is here for backwards compatibility.
node --debug `which sails` $@
*/
module.exports = function () {
var log = captains();
// Use the app's local Sails in `node_modules` if one exists
// But first make sure it'll work...
var appPath = process.cwd();
var pathToSails = path.resolve(appPath, '/node_modules/sails');
if ( !Sails.isLocalSailsValid(pathToSails, appPath) ) {
// otherwise, use the currently-running instance of Sails
pathToSails = path.resolve(__dirname, './sails.js');
}
console.log();
log.info('Running node-inspector on this app...');
log.info('If you don\'t know what to do next, type `help`');
log.info('Or check out the docs:');
log.info('http://nodejs.org/api/debugger.html');
console.log();
log.info(('( to exit, type '+'<CTRL>+<C>'+' )').grey);
console.log();
// Spin up child process for Sails
Womb.spawn('node', ['--debug', pathToSails, 'lift'], { stdio: 'inherit' });
};