#!/usr/bin/env node

/**
 * @description File size checker.
 * @author sota1235
 */

"use strict";

import { create } from 'node-getopt';
import glob from 'glob';
import checkFileSize from './size-checker';

// get arguments
const opt = create([
  ['',  'files=ARG', 'target files for lint'],
  ['',  'limit=ARG', 'limit size'],
  ['h', 'help',      'display this help'],
]).bindHelp().parseSystem();

const targetFiles = opt.options.files;
const limitSize   = opt.options.limit;

glob(targetFiles, (err, files) => {
  const promises = [];

  for (let file of files) {
    promises.push(checkFileSize(file, limitSize));
  }

  Promise.all(promises)
    .then(result => console.log('finish!'))
    .catch(err => console.error(`something error, ${err}`));
});

@@ -679,14 +679,26 @@
 og('
+All check 
 finish
+ed
 !'))
@@ -715,16 +715,24 @@
 h(err =%3E
+ %7B%0A     
  console
@@ -764,15 +764,44 @@
 $%7Berr%7D%60)
+%0A      process.exit(1);%0A    %7D
 );%0A%7D);%0A

fix error message and command status