"use strict";
var config_1 = require("../config");
var Rx = require('rx');
function default_1(task, trigger) {
    return function (options, ctx, done) {
        if (task.command === 'exit') {
            trigger.config.signalObserver.onNext({
                type: config_1.SignalTypes.Exit,
                data: {
                    code: 0
                }
            });
            process.nextTick(function () {
                done();
            });
            return;
        }
        if (task.command.indexOf('delay') === 0) {
            var split = task.command.split(' ');
            if (split.length !== 2) {
                return done(new Error('Incorrect usage. Try: @cb <number>'));
            }
            else {
                var isNum = split[1].match(/^[\d]+$/);
                if (!isNum) {
                    return done(new Error('Incorrect usage. Try: @cb <number>'));
                }
                return Rx.Observable.empty().delay(Number(split[1]), ctx.config.scheduler);
            }
        }
        return done(new Error('Command not supported'));
    };
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
//# sourceMappingURL=@cb.js.map