{"size": 1694, "ext": "js", "max_stars_repo_path": "bin/server.js", "max_stars_repo_name": "jugaz/commander-gulp-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bin/server.js", "max_issues_repo_name": "jugaz/commander-gulp-server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "bin/server.js", "max_forks_repo_name": "jugaz/commander-gulp-server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.3225806452, "max_line_length": 110, "alphanum_fraction": 0.4014167651}
#!/usr/bin/env node

var
    program = require('commander'),
    path = require('path'),
    util = require('gulp-util'),
    browserSync = require('browser-sync').create();



/* ######################## OPTIONS ######################## */
var options = {};


/* ######################## VERSION ######################## */
program
    .version(
        'commander-gulp-server version: ' + require('../package.json').version + '\n'
    )


/* ######################## GULP TEMPLATES ######################## */
// node ./bin/server.js server \"8080\" --ser \"docs/\""
program
    .command('server <dir>')
    .option("--ser [options]")
    .action((input, options) => {
        var input = options.input || options.parent.rawArgs;
        var ouput = options.ouput || options.ser;
    
        input = input.filter(function (index, value) {
            if (path.extname(index) == isNaN(index)) {
                return index;               
            }
        });

        if(input.length === 0 || input === "undefine") {
            return util.log("Error: El puerto no existe o está activado. Debe ser un número: 'Ejemplo(8080)'")
        }
        else {
            return browserSync.init({
                port: parseInt(input),
                watch: true,
                open: true,
                server: {
                    baseDir: ouput,
                    serveStaticOptions: {
                        extensions: [
                            "html",
                            "css",
                            "js"
                        ]
                    }
                }            
            });  
        }
       
    })

program.parse(process.argv);

