I currently have this code that is controlling my CLI flow:

const FLOW = [
].reduce((m, fn) => {
  cli.info(`${fn} phase starting.`);
  let current = extract[fn];

  // Ensure that all my itens inside FLOW are functions
  if (Object.prototype.toString.call(current) !== '[object Function]') {
    cli.error('You have a non-function in your FLOW.');

  let result = new current(m).process(); // Store the new MAP
  cli.info(`${fn} phase ending.`);
  return result;
}, MAP);

I'm working with files, so i'm using sync code.

at each stage I have some code that looks like the other phases:

module.exports = Class NameOfPhase {
   constructor (MAP) {
     this.MAP = MAP || {};

   process () {

And I'm using these lines to print the current phase:

cli.info(`${fn} phase starting.`);
cli.info(`${fn} phase ending.`);

I would like to improve the initializer. I don't want let this lines there. Do you have some suggestions for me? Also, are there any ways to improve the code?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.