<commit_before>#!/usr/bin/env node
'use strict'

process.title = 'netiam'

const resolve = require('resolve')
const exit = require('exit')

resolve('netiam-cli', {
  basedir: process.cwd()
}, (err, projectLocalCli) => {
  let cli

  if (err) {
    cli = require('../lib/cli')
  } else {
    cli = require(projectLocalCli)
  }

  cli({
    cliArgs: process.argv.slice(2),
    inputStream: process.stdin,
    outputStream: process.stdout
  })
    .then(result => {
      var exitCode = typeof result === 'object' ? result.exitCode : result
      exit(exitCode)
    })
    .catch(err => {
      console.error(err)
      console.error(err.stack)
    })

})
<commit_msg>refactor: use sync version to require cli<commit_after>#!/usr/bin/env node
'use strict'

process.title = 'netiam'

const resolve = require('resolve')
const exit = require('exit')

let cli
try {
  const projectLocalCli = resolve.sync('netiam-cli', {basedir: process.cwd()})
  cli = require(projectLocalCli)
} catch (err) {
  cli = require('../src/cli')
}

cli({
  cliArgs: process.argv.slice(2),
  inputStream: process.stdin,
  outputStream: process.stdout
})
  .then(result => {
    const exitCode = typeof result === 'object' ? result.exitCode : result
    exit(exitCode)
  })
  .catch(err => console.error(err))

{'fraction_non_alphanumeric': 0.16184519155590305, 'fraction_numerical': 0.001563721657544957, 'mean_word_length': 3.4290657439446366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '598440', 'n_tokens_mistral': 453, 'n_tokens_neox': 437, 'n_words': 95}