<commit_before>#!/usr/bin/env node

/*
 * ol-app-setup
 *
 * (c) 2015 <NAME>, http://www.meggsimum.de
 *
 * Licensed under MIT-License, for full license text see LICENSE-file
 */

// core modules
var fs = require('fs');
var http = require('http');

// 3rd party modules
var program = require('commander');
var connect = require('connect');
var serveStatic = require('serve-static');

var profiles = {
    ol3: {
        js: 'node_modules/openlayers/dist/ol.js',
        css: 'node_modules/openlayers/css/ol.css',
        idxTpl: 'templates/index.ol3.template',
        appJsTpl: 'templates/app.ol3.template'
    },
    ol2: {
        js: 'libs/OpenLayers-2.13.1.js',
        css: 'libs/OpenLayers-2.13.1.css',
        idxTpl: 'templates/index.ol2.template',
        appJsTpl: 'templates/app.ol2.template'
    },
    jquery: {
        js: 'node_modules/jquery/dist/jquery.min.js'
    },
    bootstrap3: {
        js: 'node_modules/bootstrap/dist/js/bootstrap.min.js',
        css: 'node_modules/bootstrap/dist/css/bootstrap.min.css'
    }
};

program
    .option('-t, --target <folder>', 'Path to create the app within (required)')
    .option('-v, --olversion <majorversion>', 'Defines the library profile to be ' +
        'used for the app setup. Valid options are "ol3" and "ol2". ' +
        '(Default is "ol3")')
    .option('-j, --jquery', 'Includes jQuery in your app setup')
    .option('-b, --bootstrap', 'Includes bootstrap in your app setup')
    .option('-s, --server', 'Start an internal web server on localhost:8888')
    .parse(process.argv);

if (!program.target) {
    program.help();
    process.exit(1);
}

var olVersion = program.olversion || 'ol3';
var libProfile = profiles[olVersion];
if(!libProfile) {
    program.help();
    process.exit(1);
}

var targetFolder = program.target;
if(!strEndsWith(targetFolder, "/")) {
    targetFolder += "/";
}

// create output folder if not existing
var libFolder = targetFolder + "/" + "libs";
if(!fs.existsSync(targetFolder)) {
    fs.mkdir(targetFolder);
}
if(!fs.existsSync(libFolder)) {
    fs.mkdir(libFolder);
}

// copy local library files

// the app root path while executing in a global context
var appRoot = __dirname + '/';

// ol
copyFile(appRoot + libProfile.js, libFolder + "/ol.js");
copyFile(appRoot + libProfile.css, libFolder + "/ol.css");

if(program.jquery) {
    // jQuery
    copyFile(appRoot + profiles.jquery.js, libFolder + "/jquery.js");
}
if(program.bootstrap) {
    // bootstrap
    copyFile(appRoot + profiles.bootstrap3.js, libFolder + "/bootstrap3.js");<commit_msg>Create target folders synchronously<commit_after>#!/usr/bin/env node

/*
 * ol-app-setup
 *
 * (c) 2015 <NAME>, http://www.meggsimum.de
 *
 * Licensed under MIT-License, for full license text see LICENSE-file
 */

// core modules
var fs = require('fs');
var http = require('http');

// 3rd party modules
var program = require('commander');
var connect = require('connect');
var serveStatic = require('serve-static');

var profiles = {
    ol3: {
        js: 'node_modules/openlayers/dist/ol.js',
        css: 'node_modules/openlayers/css/ol.css',
        idxTpl: 'templates/index.ol3.template',
        appJsTpl: 'templates/app.ol3.template'
    },
    ol2: {
        js: 'libs/OpenLayers-2.13.1.js',
        css: 'libs/OpenLayers-2.13.1.css',
        idxTpl: 'templates/index.ol2.template',
        appJsTpl: 'templates/app.ol2.template'
    },
    jquery: {
        js: 'node_modules/jquery/dist/jquery.min.js'
    },
    bootstrap3: {
        js: 'node_modules/bootstrap/dist/js/bootstrap.min.js',
        css: 'node_modules/bootstrap/dist/css/bootstrap.min.css'
    }
};

program
    .option('-t, --target <folder>', 'Path to create the app within (required)')
    .option('-v, --olversion <majorversion>', 'Defines the library profile to be ' +
        'used for the app setup. Valid options are "ol3" and "ol2". ' +
        '(Default is "ol3")')
    .option('-j, --jquery', 'Includes jQuery in your app setup')
    .option('-b, --bootstrap', 'Includes bootstrap in your app setup')
    .option('-s, --server', 'Start an internal web server on localhost:8888')
    .parse(process.argv);

if (!program.target) {
    program.help();
    process.exit(1);
}

var olVersion = program.olversion || 'ol3';
var libProfile = profiles[olVersion];
if(!libProfile) {
    program.help();
    process.exit(1);
}

var targetFolder = program.target;
if(!strEndsWith(targetFolder, "/")) {
    targetFolder += "/";
}

// create output folder if not existing
var libFolder = targetFolder + "/" + "libs";
if(!fs.existsSync(targetFolder)) {
    fs.mkdirSync(targetFolder);
}
if(!fs.existsSync(libFolder)) {
    fs.mkdirSync(libFolder);
}

// copy local library files

// the app root path while executing in a global context
var appRoot = __dirname + '/';

// ol
copyFile(appRoot + libProfile.js, libFolder + "/ol.js");
copyFile(appRoot + libProfile.css, libFolder + "/ol.css");

if(program.jquery) {
    // jQuery
    copyFile(appRoot + profiles.jquery.js, libFolder + "/jquery.js");
}
if(program.bootstrap) {
    // bootstrap
    copyFile(appRoot + profiles.bootstrap3.js, libFolder + "/bootstrap3.js");
{'fraction_non_alphanumeric': 0.16511266511266512, 'fraction_numerical': 0.012432012432012432, 'mean_word_length': 3.1457326892109503, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4748156', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1700, 'n_words': 392}