<commit_before>/* jshint node: true */
var path = require("path"),
    fs = require("fs");

module.exports = function(grunt) {
    "use strict";

    grunt.registerTask("release", [
        "clean",
        "package",
        "prepare-npm",
        "publish-npm",
        "aws_s3:release"
    ]);

    grunt.registerTask("release-develop", [
        "aws_s3:clean",
        "clean",
        "package",
        "prepare-npm",
        "aws_s3:develop"
    ]);

    grunt.registerTask("release-travis", function() {
        if (process.env.TRAVIS_PULL_REQUEST === "false") {
            if (process.env.TRAVIS_BRANCH === "master") {
                grunt.task.run("release");
            }
            else if (process.env.TRAVIS_BRANCH === "develop") {
                grunt.task.run("release-develop");
            }
        }
    });

    grunt.registerTask("prepare-npm", function() {
        // copy package.json into ./_dist
        // npm publish from that directory
        var paths = grunt.config.get("paths"),
            pkgJsonCopy = JSON.parse(JSON.stringify(grunt.config.get("pkg"))),
            npmIgnore = "*.zip";

        ["devDependencies", "scripts", "directories", "main"].forEach(function(k) {
            delete pkgJsonCopy[k];
        });

        fs.writeFileSync(path.join(paths.dist, "package.json"), JSON.stringify(pkgJsonCopy, null, 2));
        fs.writeFileSync(path.join(paths.dist, ".npmignore"), npmIgnore);

    });
<commit_msg>chore: add grunt task to publish to npm<commit_after>/* jshint node: true */
var path = require("path"),
    npm = require("npm"),
    fs = require("fs");

module.exports = function(grunt) {
    "use strict";

    grunt.registerTask("release", [
        "clean",
        "package",
        "prepare-npm",
        "publish-npm",
        "aws_s3:release"
    ]);

    grunt.registerTask("release-develop", [
        "aws_s3:clean",
        "clean",
        "package",
        "prepare-npm",
        "aws_s3:develop"
    ]);

    grunt.registerTask("release-travis", function() {
        if (process.env.TRAVIS_PULL_REQUEST === "false") {
            if (process.env.TRAVIS_BRANCH === "master") {
                grunt.task.run("release");
            }
            else if (process.env.TRAVIS_BRANCH === "develop") {
                grunt.task.run("release-develop");
            }
        }
    });

    grunt.registerTask("prepare-npm", function() {
        // copy package.json into ./_dist
        // npm publish from that directory
        var paths = grunt.config.get("paths"),
            pkgJsonCopy = JSON.parse(JSON.stringify(grunt.config.get("pkg"))),
            npmIgnore = "*.zip";

        ["devDependencies", "scripts", "directories", "main"].forEach(function(k) {
            delete pkgJsonCopy[k];
        });

        fs.writeFileSync(path.join(paths.dist, "package.json"), JSON.stringify(pkgJsonCopy, null, 2));
        fs.writeFileSync(path.join(paths.dist, ".npmignore"), npmIgnore);

    });

    grunt.registerTask("publish-npm", function() {
        var paths = grunt.config.get("paths"),
            pkg = grunt.config.get("pkg"),
            done = this.async();

        npm.load({}, function(err) {
            if (err) {
                console.log(err);
                return done(err);
            }
            npm.registry.adduser(process.env.NPM_USERNAME, process.env.NPM_PASSWORD, process.env.NPM_EMAIL, function(err) {
                if (err) {
                    console.log(err);
                    return done(err);
                }

                npm.config.set("email", process.env.NPM_EMAIL, "user");
                npm.commands.publish([paths.dist], function(err) {
                    if (err) {
                        console.log(err);
                        return done(err);
                    }
                    console.log(paths.dist + " v" + pkg.verison + " Published to registry");
                    return done();

                });

            });

        });
    });

{'fraction_non_alphanumeric': 0.15746063484128967, 'fraction_numerical': 0.001999500124968758, 'mean_word_length': 1.8044849334267694, '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': '893324', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1164, 'n_words': 194}