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

var scriptName = process.argv[2];

var isSilent = process.argv.indexOf('-s') > -1 || process.argv.indexOf('--silent') > -1;

isSilent || console.log('running better-npm-run in', process.cwd());
var join = require('path').join;
var fullPackagePath = join(process.cwd(), 'package.json');
var pkg = require(fullPackagePath);
var exec = require('./lib/exec.js');

if (!pkg.scripts) {
  process.stderr.write('ERROR: No scripts found!');
  process.exit(1);
}
if (!pkg.betterScripts) {
  process.stderr.write('ERROR: No betterScripts found!');
  process.exit(1);
}
if (!scriptName) {
  process.stderr.write('ERROR: No script name provided!');
  process.exit(1);
}
if (!pkg.betterScripts[scriptName]) {
  process.stderr.write('ERROR: No betterScript with name "'+scriptName+'" was found!');
  process.exit(1);
}


isSilent || console.log('Executing script: ' + scriptName + '\n');


exec(pkg.betterScripts[scriptName], isSilent, function (error, stdout, stderr) {
  process.stderr.write(stderr);
  process.stdout.write(stdout);
  if(error !== null) {
    console.log('exec error: '+error);
  }
});

//
// Silent mode feature added. Closing #60
//
// Running with -s or --silent flag will silence not only npm noise but also info messages of better-npm-run itself.
<commit_msg>Silent mode feature added. Closing #60<commit_after>#!/usr/bin/env node

var scriptName = process.argv[2];

var isSilent = process.argv.indexOf('-s') > -1 || process.argv.indexOf('--silent') > -1;

isSilent || console.log('running better-npm-run in', process.cwd());
var join = require('path').join;
var fullPackagePath = join(process.cwd(), 'package.json');
var pkg = require(fullPackagePath);
var exec = require('./lib/exec.js');

if (!pkg.scripts) {
  process.stderr.write('ERROR: No scripts found!');
  process.exit(1);
}
if (!pkg.betterScripts) {
  process.stderr.write('ERROR: No betterScripts found!');
  process.exit(1);
}
if (!scriptName) {
  process.stderr.write('ERROR: No script name provided!');
  process.exit(1);
}
if (!pkg.betterScripts[scriptName]) {
  process.stderr.write('ERROR: No betterScript with name "'+scriptName+'" was found!');
  process.exit(1);
}


isSilent || console.log('Executing script: ' + scriptName + '\n');


exec(pkg.betterScripts[scriptName], isSilent, function (error, stdout, stderr) {
  process.stderr.write(stderr);
  process.stdout.write(stdout);
  if(error !== null) {
    console.log('exec error: '+error);
  }
});


{'fraction_non_alphanumeric': 0.1839546191247974, 'fraction_numerical': 0.007293354943273906, 'mean_word_length': 4.702078521939954, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6007514', 'n_tokens_mistral': 847, 'n_tokens_neox': 823, 'n_words': 190}