forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsails-deploy.js
67 lines (55 loc) · 1.84 KB
/
sails-deploy.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
/**
* Module dependencies
*/
var _ = require('lodash');
var util = require('util');
var path = require('path');
var rconf = require('../lib/app/configuration/rc');
/**
* `sails deploy`
*
* Deploy the Sails app in the current directory to a hosting provider.
*
* @stability 1
*/
module.exports = function() {
var commands = rconf.commands;
var deploy = commands && commands.deploy;
var modulePath = deploy && deploy.module;
var module;
// If no module path was specified, bail out
if (!modulePath) {
console.error('No module specified for the `deploy` command.');
console.error('To use `sails deploy`, set a `commands.deploy.module` setting in your .sailsrc file');
return;
}
// Attempt to require the specified module from the project node_modules folder
try {
module = require(path.resolve(process.cwd(), 'node_modules', modulePath));
}
// If the module couldn't be required, bail out
catch (e) {
console.error('Could not require module at path: ' + modulePath + '. Please check the path and try again.');
}
try {
// Attempt to run the deploy command
module({config: rconf}, function(err, result) {
// If there were any issues, log them to the console.
if (err) {
console.error('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
console.error('Deployment failed! Details below:');
console.error('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
console.error(err);
}
});
}
// Chances are we won't catch any errors internal to the deploy command here;
// this would probably be an error at the top level of the deploy script.
catch(e) {
console.error('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
console.error('Could not run deploy! Details below:');
console.error('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-');
console.error(e);
}
};