function copyAction(command, options) {
  const { verbose } = options;

  if (!command.source || !command.destination) {
    if (verbose) {
      console.log(
        '  - FileManagerPlugin: Warning - copy parameter has to be formated as follows: { source: <string>, destination: <string> }',
      );
    }
    return null;
  }

  return () =>
    new Promise((resolve, reject) => {
      // if source is a file, just copyFile()
      // if source is a NOT a glob pattern, simply append **/*
      const fileRegex = /(\*|\{+|\}+)/g;
      const matches = fileRegex.exec(command.source);

      if (matches === null) {
        fs.lstat(command.source, (sErr, sStats) => {
          if (sErr) return reject(sErr);

          fs.lstat(command.destination, (dErr, dStats) => {
            if (sStats.isFile()) {
              const destination =
                dStats && dStats.isDirectory()
                  ? command.destination + '/' + path.basename(command.source)
                  : command.destination;

              if (verbose) {
                console.log(
                  `  - FileManagerPlugin: Start copy source: ${command.source} to destination: ${destination}`,
                );
              }

              /*
               * If the supplied destination is a directory copy inside.
               * If the supplied destination is a directory that does not exist yet create it & copy inside
               */

              const pathInfo = path.parse(destination);

              const execCopy = (src, dest) => {
                fsExtra.copy(src, dest, err => {
                  if (err) reject(err);
                  resolve();
                });
              };

              if (pathInfo.ext === '') {
                makeDir(destination).then(mPath => {
                  execCopy(command.source, destination + '/' + path.basename(command.source));
                });
              } else {
                execCopy(command.source, destination);
              }
            } else {
              const sourceDir = command.source + (command.source.substr(-1) !== '/' ? '/' : '') + '**/*';
              copyDirectory(sourceDir, command.destination, resolve, reject, options);
            }
          });
        });
      } else {
        copyDirectory(command.source, command.destination, resolve, reject, options);
      }
    });
}
/**
 * Execute copy action
 *
 * @param {Object} command - Command data for given action
 * @return {Function|null} - Function that returns a promise or null
 */
Execute copy action
@param {Object} command - Command data for given action
@return {Function|null} - Function that returns a promise or null
Execute copy action @param { Object } command - Command data for given action @return { Function|null } - Function that returns a promise or null
function copyAction(command, options) {
  const { verbose } = options;
  if (!command.source || !command.destination) {
    if (verbose) {
      console.log(
        '  - FileManagerPlugin: Warning - copy parameter has to be formated as follows: { source: <string>, destination: <string> }',
      );
    }
    return null;
  }
  return () =>
    new Promise((resolve, reject) => {
      const fileRegex = /(\*|\{+|\}+)/g;
      const matches = fileRegex.exec(command.source);
      if (matches === null) {
        fs.lstat(command.source, (sErr, sStats) => {
          if (sErr) return reject(sErr);
          fs.lstat(command.destination, (dErr, dStats) => {
            if (sStats.isFile()) {
              const destination =
                dStats && dStats.isDirectory()
                  ? command.destination + '/' + path.basename(command.source)
                  : command.destination;
              if (verbose) {
                console.log(
                  `  - FileManagerPlugin: Start copy source: ${command.source} to destination: ${destination}`,
                );
              }
              const pathInfo = path.parse(destination);
              const execCopy = (src, dest) => {
                fsExtra.copy(src, dest, err => {
                  if (err) reject(err);
                  resolve();
                });
              };
              if (pathInfo.ext === '') {
                makeDir(destination).then(mPath => {
                  execCopy(command.source, destination + '/' + path.basename(command.source));
                });
              } else {
                execCopy(command.source, destination);
              }
            } else {
              const sourceDir = command.source + (command.source.substr(-1) !== '/' ? '/' : '') + '**/*';
              copyDirectory(sourceDir, command.destination, resolve, reject, options);
            }
          });
        });
      } else {
        copyDirectory(command.source, command.destination, resolve, reject, options);
      }
    });
}
function copyAction ( command , options ) { const { verbose } = options ; if ( ! command . source || ! command . destination ) { if ( verbose ) { console . log ( '  - FileManagerPlugin: Warning - copy parameter has to be formated as follows: { source: <string>, destination: <string> }' , ) ; } return null ; } return ( ) => new Promise ( ( resolve , reject ) => { const fileRegex = / (\*|\{+|\}+) / g ; const matches = fileRegex . exec ( command . source ) ; if ( matches === null ) { fs . lstat ( command . source , ( sErr , sStats ) => { if ( sErr ) return reject ( sErr ) ; fs . lstat ( command . destination , ( dErr , dStats ) => { if ( sStats . isFile ( ) ) { const destination = dStats && dStats . isDirectory ( ) ? command . destination + '/' + path . basename ( command . source ) : command . destination ; if ( verbose ) { console . log ( ` ${ command . source } ${ destination } ` , ) ; } const pathInfo = path . parse ( destination ) ; const execCopy = ( src , dest ) => { fsExtra . copy ( src , dest , err => { if ( err ) reject ( err ) ; resolve ( ) ; } ) ; } ; if ( pathInfo . ext === '' ) { makeDir ( destination ) . then ( mPath => { execCopy ( command . source , destination + '/' + path . basename ( command . source ) ) ; } ) ; } else { execCopy ( command . source , destination ) ; } } else { const sourceDir = command . source + ( command . source . substr ( - 1 ) !== '/' ? '/' : '' ) + '**/*' ; copyDirectory ( sourceDir , command . destination , resolve , reject , options ) ; } } ) ; } ) ; } else { copyDirectory ( command . source , command . destination , resolve , reject , options ) ; } } ) ; }
Execute copy action
 @param {Object} command - Command data for given action
 @return {Function|null} - Function that returns a promise or null
Execute copy action @param { Object } command - Command data for given action @return { Function|null } - Function that returns a promise or null
// if source is a file, just copyFile() // if source is a NOT a glob pattern, simply append **/* /*
               * If the supplied destination is a directory copy inside.
               * If the supplied destination is a directory that does not exist yet create it & copy inside
               */