All files / src index.js

100% Statements 17/17
100% Branches 4/4
100% Functions 4/4
100% Lines 15/15
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    5x 5x 5x 5x 5x     5x                       4x   4x               1x                 5x   5x 1x       5x   5x 5x  
'use strict';
 
const program = require('commander');
const { version } = require('../package.json');
const commands = require('./commands');
const getArgv = require('./utils/get-argv');
const { kill } = require('./utils/child-process');
 
// deploy
program
    .version(version)
    .command('deploy [service]')
    .allowUnknownOption()
    .option(
        '-b, --runInBand',
        'Deploy services one by one (parallel by default)'
    )
    .option('-e, --exitOnFailure', 'Stop deployment on failure')
    .option('-r, --rollbackOnFailure', 'Rollback deployed services on failure')
    .option('-v, --verbose', 'Show summary of serverless output')
    .action((service, options) => {
        const args = program.rawArgs.slice(service ? 4 : 3);
 
        commands.deploy(
            service,
            process.cwd(),
            getArgv(args, program.commands[0].options),
            options
        );
    })
    .on('--help', () => {
        process.stdout.write(`
  Examples:
 
    deploy
    deploy all
    deploy path/to/app
    `);
    });
 
program.parse(process.argv);
 
if (program.args.length === 0) {
    program.outputHelp();
}
 
// kill all child processes on exit
process.on('exit', kill);
// handle kill signals
process.on('SIGINT', () => process.exit(0));
process.on('SIGTERM', () => process.exit(0));