<commit_before>const Task            = require('../../../tasks/-task');
const cordovaPath     = require('../utils/get-path');
const fork            = require('../../../utils/fork');
const path            = require('path');
const chalk           = require('chalk');

const runnerPath = path.resolve(
  __dirname, '..', '..', '..', '..',
  'bin',
  'cordova-lib-runner'
);

module.exports = Task.extend({
  project: undefined,
  api: undefined,

  onStdout: (output) => console.log(output),
  onStderr: (output) => console.log(chalk.red(output)),

  cordovaPromise(...args) {
    args.unshift(this.api);

    return fork(runnerPath, args, {
      onStdout: this.onStdout,
      onStderr: this.onStderr
    });
  },

  run() {
    let processPath = process.cwd();

    //Much of cordova-lib has a hardcoded process.cwd()
    //This won't work for us
    process.chdir(cordovaPath(this.project));

    return this.cordovaPromise(...arguments).finally(() => {
      process.chdir(processPath);<commit_msg>feat(raw-task): pipe stdout and stderr to logger<commit_after>const Task            = require('../../../tasks/-task');
const cordovaPath     = require('../utils/get-path');
const fork            = require('../../../utils/fork');
const logger          = require('../../../utils/logger');
const path            = require('path');

const runnerPath = path.resolve(
  __dirname, '..', '..', '..', '..',
  'bin',
  'cordova-lib-runner'
);

module.exports = Task.extend({
  project: undefined,
  api: undefined,

  onStdout: (data) => logger.verbose(data),
  onStderr: (data) => logger.error(data),

  cordovaPromise(...args) {
    args.unshift(this.api);

    return fork(runnerPath, args, {
      onStdout: this.onStdout,
      onStderr: this.onStderr
    });
  },

  run() {
    let processPath = process.cwd();

    //Much of cordova-lib has a hardcoded process.cwd()
    //This won't work for us
    process.chdir(cordovaPath(this.project));

    return this.cordovaPromise(...arguments).finally(() => {
      process.chdir(processPath);
{'fraction_non_alphanumeric': 0.1900785854616896, 'fraction_numerical': 0.0, 'mean_word_length': 2.6375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4916598', 'n_tokens_mistral': 669, 'n_tokens_neox': 645, 'n_words': 129}