<commit_before>/*globals define*/
define(['coreplugins/PluginGenerator/PluginGenerator',
        'plugin/PluginBase',
        'commands/shim/blobClient',
        'lodash',
        'path',
        'commands/../utils',
        'ramda'], function(WebGMEPluginGenerator,
                           PluginBase,
                           BlobClient,
                           _,
                           path,
                           utils,
                           R) {
    'use strict';
    
    var TEST_FIXTURE_DIR = '../../globals';
    var PluginGenerator = function(logger, config) {
        // Load the PluginGenerator from the core plugins
        // Use it to create the boilerplate for the new plugin
        WebGMEPluginGenerator.call(this);
        var blobClient = new BlobClient();
        this.initialize(logger, blobClient);
        this._currentConfig = config;
        this.logger = logger;
        this.configure({});
        this.META = {};
    };

    _.extend(PluginGenerator.prototype, 
             PluginBase.prototype, 
             WebGMEPluginGenerator.prototype);

    PluginGenerator.prototype.initialize = function(logger, blob) {
        this.blobClient = blob;
        this.logger = logger;
    };

    // Helper function for the PluginGenerator
    var fixFilePath = function(file) {
        file.name = file.name.replace('undefined'+path.sep, '');
        // Change "plugins" to "plugin"
        file.name = file.name.replace('plugins', 'plugin');
    };

    var fixFixturePath = function(file) {
        // Get the current path
        var regex = /testFixture = require\(['"]{1}(.*)['"]{1}\)/,
            oldPath = file.content.match(regex);

        file.content = file.content.replace(oldPath[1], TEST_FIXTURE_DIR);
    };


    // Make the src/plugins test/plugins directories as needed
    PluginGenerator.prototype.main = function() {
        var self = this;
        WebGMEPluginGenerator.prototype.main.call(this, function(e, result) {
            if (e) {
                return this.logger.error(e);
            }

            // Fix any file names
            R.values(self.blobClient.artifacts).forEach(function(artifact) {
                artifact.files.forEach(fixFilePath);
                // Fix the require path for the unit test
                var test = artifact.files.filter(function(file) {
                    return file.name.indexOf('test') === 0;
                })[0];
                if (test) {  // If they are generating test file
                    fixFixturePath(test);
                }

                artifact.files.forEach(function(file) {
                    self.logger.info('Saving file at '+file.name);
                });
            });

            // Save all BlobClient Artifacts to the fs
            utils.saveFilesFromBlobClient(self.blobClient);
        });
    };

    return PluginGenerator;
});
<commit_msg>Replaced path.sep with /. Fixes #29<commit_after>/*globals define*/
define(['coreplugins/PluginGenerator/PluginGenerator',
        'plugin/PluginBase',
        'commands/shim/blobClient',
        'lodash',
        'path',
        'commands/../utils',
        'ramda'], function(WebGMEPluginGenerator,
                           PluginBase,
                           BlobClient,
                           _,
                           path,
                           utils,
                           R) {
    'use strict';
    
    var TEST_FIXTURE_DIR = '../../globals';
    var PluginGenerator = function(logger, config) {
        // Load the PluginGenerator from the core plugins
        // Use it to create the boilerplate for the new plugin
        WebGMEPluginGenerator.call(this);
        var blobClient = new BlobClient();
        this.initialize(logger, blobClient);
        this._currentConfig = config;
        this.logger = logger;
        this.configure({});
        this.META = {};
    };

    _.extend(PluginGenerator.prototype, 
             PluginBase.prototype, 
             WebGMEPluginGenerator.prototype);

    PluginGenerator.prototype.initialize = function(logger, blob) {
        this.blobClient = blob;
        this.logger = logger;
    };

    // Helper function for the PluginGenerator
    var fixFilePath = function(file) {
        file.name = file.name.replace('undefined/', '');
        // Change "plugins" to "plugin"
        file.name = file.name.replace('plugins', 'plugin');
    };

    var fixFixturePath = function(file) {
        // Get the current path
        var regex = /testFixture = require\(['"]{1}(.*)['"]{1}\)/,
            oldPath = file.content.match(regex);

        file.content = file.content.replace(oldPath[1], TEST_FIXTURE_DIR);
    };


    // Make the src/plugins test/plugins directories as needed
    PluginGenerator.prototype.main = function() {
        var self = this;
        WebGMEPluginGenerator.prototype.main.call(this, function(e, result) {
            if (e) {
                return this.logger.error(e);
            }

            // Fix any file names
            R.values(self.blobClient.artifacts).forEach(function(artifact) {
                artifact.files.forEach(fixFilePath);
                // Fix the require path for the unit test
                var test = artifact.files.filter(function(file) {
                    return file.name.indexOf('test') === 0;
                })[0];
                if (test) {  // If they are generating test file
                    fixFixturePath(test);
                }

                artifact.files.forEach(function(file) {
                    self.logger.info('Saving file at '+file.name);
                });
            });

            // Save all BlobClient Artifacts to the fs
            utils.saveFilesFromBlobClient(self.blobClient);
        });
    };

    return PluginGenerator;
});

{'fraction_non_alphanumeric': 0.11494845360824742, 'fraction_numerical': 0.002061855670103093, 'mean_word_length': 1.656777727065267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5698563', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1470, 'n_words': 326}