"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const childProcess = require('child_process');
const fs = require('fs');
function generate(yaml, output, callback) {
    if (fs.existsSync(yaml)) {
        const codegen = childProcess.spawn('java', [
            '-jar', __dirname + '/../../bin/swagger-codegen-cli.jar', 'generate', '-i', yaml, '-l',
            'typescript-angular2', '-o', output
        ]);
        codegen.stdout.on('data', (data) => {
            console.log(data.toString());
        });
        codegen.stderr.on('data', (data) => {
            console.error(data.toString());
        });
        codegen.on('close', (code) => {
            if (callback) {
                if (code && code === 0) {
                    return callback();
                }
                return callback(code);
            }
        });
    }
    else {
        if (callback) {
            return callback();
        }
    }
}
exports.generate = generate;
function watch(yaml, output, callback) {
    if (fs.existsSync(yaml)) {
        fs.watch(yaml, (_, filename) => {
            return generate(filename, output, callback);
        });
    }
}
exports.watch = watch;
//# sourceMappingURL=/home/ddavis/Projects/xtivia/speedray/speedray-cli/lib/speedray/swagger.js.map