All files / src/serverless/deploy-multiple/deploy-one index.js

100% Statements 17/17
100% Branches 6/6
100% Functions 4/4
100% Lines 16/16
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    1x 1x   4x 4x             1x         1x     3x   3x     2x 1x   2x   1x 1x     3x 3x 3x          
'use strict';
 
const deploy = require('./deploy');
const createStatusStream = require('../status-stream');
 
module.exports = ({ path, flags, config, logStream, color }) => (ctx, task) =>
    deploy({
        path,
        flags,
        logStream,
        stdout: config.verbose && createStatusStream(path, color, task)
    })
        .catch(err => {
            ctx[path] = {
                info: err.log,
                isFailed: true
            };
 
            return Promise.reject(err);
        })
        .then(res => {
            let isSkipped = false;
            // check if service was deployed
            if (
                res.stdout.indexOf('Serverless: Stack update finished...') > -1
            ) {
                if (!ctx.deployedPaths) {
                    ctx.deployedPaths = [];
                }
                ctx.deployedPaths.push(path);
            } else {
                isSkipped = true;
                task.skip();
            }
 
            const infoIndex = res.stdout.lastIndexOf('Service Information');
            const info = res.stdout.substring(infoIndex);
            ctx[path] = {
                info,
                isSkipped
            };
        });