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

import * as cliExt from 'cli-ext'
import {resolve} from './api'
import {connect} from '@buggyorg/library-client'

connect(process.env.BUGGY_LIBRARY_HOST)
.then((client) => cliExt.input(process.argv[2])
  .then((graphStr) => {
    var graph
    try {
      graph = JSON.parse(graphStr)
    } catch (err) {
      console.error('[Resolve] Cannot parse input JSON.')
    }
    return resolve(graph, client.component)
  })
)
.then((res) => console.log(JSON.stringify(res, null, 2)))
.catch((err) => console.error(err.stack || err))
<commit_msg>(fix) Fix exit code on errors.<commit_after>#!/usr/bin/env node
import * as cliExt from 'cli-ext'
import {resolve} from './api'
import {connect} from '@buggyorg/library-client'

connect(process.env.BUGGY_LIBRARY_HOST)
.then((client) => cliExt.input(process.argv[2])
  .then((graphStr) => {
    var graph
    try {
      graph = JSON.parse(graphStr)
    } catch (err) {
      throw Error('[Resolve] Cannot parse input JSON.')
    }
    return resolve(graph, client.component)
  })
)
.then((res) => console.log(JSON.stringify(res, null, 2)))
.catch((err) => {
  console.error(err.stack || err)
  process.exitCode = 1
})

{'fraction_non_alphanumeric': 0.17435037720033528, 'fraction_numerical': 0.004191114836546521, 'mean_word_length': 3.776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5031880', 'n_tokens_mistral': 427, 'n_tokens_neox': 419, 'n_words': 92}