TOTVSTEC/cloudbridge-cli

View on GitHub
src/tasks/default/build.js

Summary

Maintainability
B
5 hrs
Test Coverage
'use strict';

let Q = require('q'),
    AppTask = require('./app-task'),
    platform = cb_require('utils/platform');

class BuildTask extends AppTask {

    run(cloudbridge, argv) {
        let target = this.getPlatform(argv._[1]);

        if (target === null) {
            console.error('Invalid platform: ' + argv._[1]);
            return Q();
        }

        let BuildPlatformTask = require('./build-' + target),
            task = new BuildPlatformTask(this.options);

        return task.run(cloudbridge, argv);
    }

    getPlatform(target) {
        if (target !== undefined) {
            return platform.valid(target);
        }
        else {
            return platform.default;
        }
    }

}

module.exports = BuildTask;