<commit_before>/*
 * doploy
 *
 * Copyright(c) 2015 <NAME> <<EMAIL>>
 * MIT Licensed
 *
 */

/**
 * @author <NAME> <<EMAIL>>
 *
 */

'use strict';

var util = require('util');

var VError = require('verror');
var mandatory = require('mandatory');

var SSHTask = require('./ssh/');
var manifest = require('./manifest/')();

module.exports = function instantiate (options, callback) {
    var install = new InstallTask(options);

    return install.execute(callback);
};

function InstallTask (options) {
    SSHTask.call(this, options);
}

util.inherits(InstallTask, SSHTask);

InstallTask.prototype.execute = function execute (callback) {
    mandatory(callback).is('function', 'Please provide a proper callback function.');

    function onManifestRead (err, mani) {
        if (err) {
            return callback(new VError(err, 'please define a proper manifest file (`doploy.json`)'));
        }

        if (!mani.install || mani.install.length === 0) {
            return callback(new VError(err, 'no install commands found'));
        }
    }

    manifest.read(onManifestRead);
};<commit_msg>Switched to EventEmitter API.<commit_after>/*
 * doploy
 *
 * Copyright(c) 2015 <NAME> <<EMAIL>>
 * MIT Licensed
 *
 */

/**
 * @author <NAME> <<EMAIL>>
 *
 */

'use strict';

var events = require('events');
var util = require('util');

var VError = require('verror');

var SSHTask = require('./ssh/');
var manifest = require('./manifest/')();

module.exports = function instantiate (options, callback) {
    var install = new InstallTask(options);

    return install.execute(callback);
};

function InstallTask (options) {
    SSHTask.call(this, options);
}

util.inherits(InstallTask, SSHTask);

InstallTask.prototype.execute = function execute () {
    var ee = new events.EventEmitter();

    function onManifestRead (err, mani) {
        if (err) {
            return ee.emit('error', new VError(err, 'please define a proper manifest file (`doploy.json`)'));
        }

        if (!mani.install || mani.install.length === 0) {
            return ee.emit('error', new VError(err, 'no install commands found'));
        }

    }

    manifest.read(onManifestRead);

    return ee;
};
{'fraction_non_alphanumeric': 0.15866483767718337, 'fraction_numerical': 0.004572473708276178, 'mean_word_length': 3.3412698412698414, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2795069', 'n_tokens_mistral': 691, 'n_tokens_neox': 666, 'n_words': 173}