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

var postcss = require('postcss');
var fs = require('fs');
var _ = require('underscore');

var input = process.argv.slice(2)[0];
var output = process.argv.slice(2)[1];

if (input && output) {
    var css = fs.readFileSync(input, 'utf8');
    var result;

    var contenter = postcss(function (css) {
        result = 'define(function () { return function (module) {';

        css.eachRule(function (rule) {
            result += "module.insertRule('" + rule.selector + "', '";

            for (var i = 0; i < rule.childs.length; i++) {
                result += rule.childs[i].prop + rule.childs[i].between + rule.childs[i].value + ';';
            }

            result += "');";
        });

        css.eachAtRule(function (atrule) {
            if (atrule.name === 'import') {
                result += "module.injectRule('@" + atrule.name + ' ' + atrule.params + ";');";
            } else if (atrule.name === 'media') {
                if (atrule.childs) {
                    result += "module.injectRule('@" + atrule.name + " " + atrule.params + "{}');";

                    _.each(atrule.childs, function (rule) {
                        var temp = "@" + atrule.name + " " + atrule.params + "{" + rule.selector + "{";

                        for (var i = 0; i < rule.childs.length; i++) {
                            temp += rule.childs[i].prop + rule.childs[i].between + rule.childs[i].value + ';';
                        }

                        temp += '}';

                        result += "module.injectMediaRule('" + temp + "');";<commit_msg>avoid populating a rule if it's a child of an atrule<commit_after>#!/usr/bin/env node

var postcss = require('postcss');
var fs = require('fs');
var _ = require('underscore');

var input = process.argv.slice(2)[0];
var output = process.argv.slice(2)[1];

if (input && output) {
    var css = fs.readFileSync(input, 'utf8');
    var result;

    var contenter = postcss(function (css) {
        result = 'define(function () { return function (module) {';

        css.eachRule(function (rule) {
            if (rule.parent.type === 'root') {
                result += "module.insertRule('" + rule.selector + "', '";

                for (var i = 0; i < rule.childs.length; i++) {
                    result += rule.childs[i].prop + rule.childs[i].between + rule.childs[i].value + ';';
                }

                result += "');";
            }
        });

        css.eachAtRule(function (atrule) {
            if (atrule.name === 'import') {
                result += "module.injectRule('@" + atrule.name + ' ' + atrule.params + ";');";
            } else if (atrule.name === 'media') {
                if (atrule.childs) {
                    result += "module.injectRule('@" + atrule.name + " " + atrule.params + "{}');";

                    _.each(atrule.childs, function (rule) {
                        var temp = "@" + atrule.name + " " + atrule.params + "{" + rule.selector + "{";

                        for (var i = 0; i < rule.childs.length; i++) {
                            temp += rule.childs[i].prop + rule.childs[i].between + rule.childs[i].value + ';';
                        }

                        temp += '}';

                        result += "module.injectMediaRule('" + temp + "');";
{'fraction_non_alphanumeric': 0.18121613485851895, 'fraction_numerical': 0.004214328717639976, 'mean_word_length': 1.7038242473555736, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4895981', 'n_tokens_mistral': 1037, 'n_tokens_neox': 980, 'n_words': 199}