<commit_before>'use strict';

var gutil = require('gulp-util');
var glob = require('glob');
var map = require('vinyl-map');

var path = require('path');

// Constants
var PLUGIN_NAME = 'gulp-css-globbing';

var cssGlobbingPlugin = function(options) {
  if (!options) options = {};
  if (!options.extensions) options.extensions = ['.css'];
  if (!options.ignoreFolders) options.ignoreFolders = [''];

  if (typeof options.extensions == 'string') options.extensions = [options.extensions];

  if (!(options.extensions instanceof Array)) {
    throw new gutil.PluginError(PLUGIN_NAME, 'extensions needs to be a string or an array');
  }

  if (typeof options.ignoreFolders == 'string') options.ignoreFolders = [options.ignoreFolders];

  if (!(options.ignoreFolders instanceof Array)) {
    throw new gutil.PluginError(PLUGIN_NAME, 'ignore-folders needs to be a string or an array');
  }

  return map(function(code, filename) {
    var content = code.toString();
    var importRegExp = /^\s*@import\s+((?:url\()?["']?)?([^"'\)]+)(['"]?(?:\))?)?;\s*$/gm;
    var globRegExp = /\/\*/;
    var files;

    content = content.replace(importRegExp, function(result, prefix, filePattern, suffix) {
      files = [];

      if (globRegExp.exec(filePattern)) {
        glob.sync(filePattern, { cwd: path.dirname(filename) }).forEach(function(foundFilename) {
          if ((options.extensions.indexOf(path.extname(foundFilename)) !== -1)&&(options.ignoreFolders.indexOf(path.dirname(foundFilename)))) {
            files.push(foundFilename);
          }
        });

        if (files.length) {
          result = '';

          files.forEach(function(foundFilename) {
            result += '@import ' + prefix + foundFilename + suffix + ';\n';
          });
        } else {
          result = '/* No files to import found in ' + filePattern + ' */';
        }
      }

      return result;
    });

    return content;
  });
};

module.exports = cssGlobbingPlugin;
<commit_msg>bug fix for multiple folders<commit_after>'use strict';

var gutil = require('gulp-util');
var glob = require('glob');
var map = require('vinyl-map');

var path = require('path');

// Constants
var PLUGIN_NAME = 'gulp-css-globbing';

var cssGlobbingPlugin = function(options) {
  if (!options) options = {};
  if (!options.extensions) options.extensions = ['.css'];
  if (!options.ignoreFolders) options.ignoreFolders = [''];

  if (typeof options.extensions == 'string') options.extensions = [options.extensions];

  if (!(options.extensions instanceof Array)) {
    throw new gutil.PluginError(PLUGIN_NAME, 'extensions needs to be a string or an array');
  }

  if (typeof options.ignoreFolders == 'string') options.ignoreFolders = [options.ignoreFolders];

  if (!(options.ignoreFolders instanceof Array)) {
    throw new gutil.PluginError(PLUGIN_NAME, 'ignore-folders needs to be a string or an array');
  }

  return map(function(code, filename) {
    var content = code.toString();
    var importRegExp = /^\s*@import\s+((?:url\()?["']?)?([^"'\)]+)(['"]?(?:\))?)?;\s*$/gm;
    var globRegExp = /\/\*/;
    var files;

    content = content.replace(importRegExp, function(result, prefix, filePattern, suffix) {
      files = [];

      if (globRegExp.exec(filePattern)) {
        glob.sync(filePattern, { cwd: path.dirname(filename) }).forEach(function(foundFilename) {
          if ((options.extensions.indexOf(path.extname(foundFilename)) !== -1)&&(options.ignoreFolders.indexOf(path.dirname(foundFilename))) == -1) {
            files.push(foundFilename);
          }
        });

        if (files.length) {
          result = '';

          files.forEach(function(foundFilename) {
            result += '@import ' + prefix + foundFilename + suffix + ';\n';
          });
        } else {
          result = '/* No files to import found in ' + filePattern + ' */';
        }
      }

      return result;
    });

    return content;
  });
};

module.exports = cssGlobbingPlugin;

{'fraction_non_alphanumeric': 0.16906747536012132, 'fraction_numerical': 0.000758150113722517, 'mean_word_length': 3.1751054852320677, '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': '1575090', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1194, 'n_words': 265}