<commit_before>/* global process */
/* eslint no-console: 0 */

'use strict'

process.env.FORCE_COLOR = true // Force colors for packages that depend on https://www.npmjs.com/package/supports-color

const path = require('path')
const sgf = require('staged-git-files')
const appRoot = require('app-root-path')
const Listr = require('listr')
const cosmiconfig = require('cosmiconfig')

const packageJson = require(appRoot.resolve('package.json')) // eslint-disable-line
const runScript = require('./runScript')
const resolvePaths = require('./resolvePaths')
const generateTasks = require('./generateTasks')

cosmiconfig(packageJson.name, {
    rc: 'lintstaged'
})
    .then((result) => {
        // result.config is the parsed configuration object
        // result.filepath is the path to the config file that was found
        const config = result.config
        const concurrent = config.concurrent || true

        // If git-root is defined -> set git root as sgf's cwd
        if ('git-root' in config) {
            sgf.cwd = path.resolve(config['git-root'])
        }

        sgf('ACM', (err, files) => {
            if (err) {
                console.error(err)
            }

            const tasks = generateTasks(config, resolvePaths(files))
                .map(task => ({
                    title: `Running tasks for ${ task.pattern }`,
                    task: () => (new Listr(runScript(task.commands, task.fileList, packageJson)))
                }))


            if (tasks.length) {
                new Listr(tasks, { concurrent }).run().catch((error) => {
                    console.error(error)
                    process.exit(1)
                })
            }
        })
    })
    .catch((parsingError) => {
        // do something constructive
        console.error(`Could not parse lint-staged config.
Make sure you have created it. See ${ packageJson.homepage }.

${ parsingError }
`)
        process.exit(1)
    })
<commit_msg>Use name from package.json<commit_after>/* global process */
/* eslint no-console: 0 */

'use strict'

process.env.FORCE_COLOR = true // Force colors for packages that depend on https://www.npmjs.com/package/supports-color

const path = require('path')
const sgf = require('staged-git-files')
const appRoot = require('app-root-path')
const Listr = require('listr')
const cosmiconfig = require('cosmiconfig')

const packageJson = require(appRoot.resolve('package.json')) // eslint-disable-line
const runScript = require('./runScript')
const resolvePaths = require('./resolvePaths')
const generateTasks = require('./generateTasks')

cosmiconfig(packageJson.name, {
    rc: 'lintstaged'
})
    .then((result) => {
        // result.config is the parsed configuration object
        // result.filepath is the path to the config file that was found
        const config = result.config
        const concurrent = config.concurrent || true

        // If git-root is defined -> set git root as sgf's cwd
        if ('git-root' in config) {
            sgf.cwd = path.resolve(config['git-root'])
        }

        sgf('ACM', (err, files) => {
            if (err) {
                console.error(err)
            }

            const tasks = generateTasks(config, resolvePaths(files))
                .map(task => ({
                    title: `Running tasks for ${ task.pattern }`,
                    task: () => (new Listr(runScript(task.commands, task.fileList, packageJson)))
                }))


            if (tasks.length) {
                new Listr(tasks, { concurrent }).run().catch((error) => {
                    console.error(error)
                    process.exit(1)
                })
            }
        })
    })
    .catch((parsingError) => {
        // do something constructive
        console.error(`Could not parse ${ packageJson.name } config.
Make sure you have created it. See ${ packageJson.homepage }.

${ parsingError }
`)
        process.exit(1)
    })

{'fraction_non_alphanumeric': 0.13238650773522698, 'fraction_numerical': 0.001521683996956632, 'mean_word_length': 2.137629276054097, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '597645', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1068, 'n_words': 279}