<commit_before>'use strict';

var child = require('child_process');

/**
 * getCurrentNpmLs get actual version of packages via running npm list command
 * @param  {Object} options
 * @return {Promise}
 */
function getCurrentNpmLs(options) {
    return new Promise(function(resolve, reject) {
        child.exec('npm list --depth=0 --json' +
            (options.prod ? ' --prod' : '') +
            (options.dev ? ' --dev' : ''), {
                cwd: options.directory
            }, function(error, stdout, stderr) {
            var curDeps = JSON.parse(stdout).dependencies;
            resolve(curDeps);
        });
    });
}

module.exports = getCurrentNpmLs;<commit_msg>reject if npm isnt installed<commit_after>'use strict';

var child = require('child_process');

/**
 * getCurrentNpmLs get actual version of packages via running npm list command
 * @param  {Object} options
 * @return {Promise}
 */
function getCurrentNpmLs(options) {
    return new Promise(function(resolve, reject) {
        child.exec('npm list --depth=0 --json' +
            (options.prod ? ' --prod' : '') +
            (options.dev ? ' --dev' : ''), {
                cwd: options.directory
            }, function(error, stdout, stderr) {
            var curDeps;

            // if `npm` command not found
            if (error && error.code === 127) {
                reject(stderr);
                return;
            }

            curDeps = JSON.parse(stdout).dependencies;
            resolve(curDeps);
        });
    });
}

module.exports = getCurrentNpmLs;
{'fraction_non_alphanumeric': 0.13733075435203096, 'fraction_numerical': 0.003223726627981947, 'mean_word_length': 2.1102204408817635, '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': '7358968', 'n_tokens_mistral': 459, 'n_tokens_neox': 440, 'n_words': 107}