UNPKG

sails

Version:

API-driven framework for building realtime apps, using MVC conventions (based on Express and Socket.io)

62 lines (52 loc) 1.89 kB
/** * Module dependencies */ 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)); } catch (unusedErr) { // FUTURE: provide access to error details instead of swallowing // If the module couldn't be required, bail out console.error('Could not require module at path: ' + modulePath + '. Please check the path and try again.'); return; }//• try { // Attempt to run the deploy command module({config: rconf}, function(err) { // 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); } };