function copyAction(command, options) {
  var verbose = options.verbose;


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

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

          fs.lstat(command.destination, function (dErr, dStats) {
            if (sStats.isFile()) {
              var 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
               */

              var pathInfo = path.parse(destination);

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

              if (pathInfo.ext === '') {
                makeDir(destination).then(function (mPath) {
                  execCopy(command.source, destination + '/' + path.basename(command.source));
                });
              } else {
                execCopy(command.source, destination);
              }
            } else {
              var 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) {
  var verbose = options.verbose;
  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 function () {
    return new Promise(function (resolve, reject) {
      var fileRegex = /(\*|\{+|\}+)/g;
      var matches = fileRegex.exec(command.source);
      if (matches === null) {
        fs.lstat(command.source, function (sErr, sStats) {
          if (sErr) return reject(sErr);
          fs.lstat(command.destination, function (dErr, dStats) {
            if (sStats.isFile()) {
              var 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);
              }
              var pathInfo = path.parse(destination);
              var execCopy = function execCopy(src, dest) {
                fsExtra.copy(src, dest, function (err) {
                  if (err) reject(err);
                  resolve();
                });
              };
              if (pathInfo.ext === '') {
                makeDir(destination).then(function (mPath) {
                  execCopy(command.source, destination + '/' + path.basename(command.source));
                });
              } else {
                execCopy(command.source, destination);
              }
            } else {
              var 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 ) { var verbose = options . verbose ; 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 function ( ) { return new Promise ( function ( resolve , reject ) { var fileRegex = / (\*|\{+|\}+) / g ; var matches = fileRegex . exec ( command . source ) ; if ( matches === null ) { fs . lstat ( command . source , function ( sErr , sStats ) { if ( sErr ) return reject ( sErr ) ; fs . lstat ( command . destination , function ( dErr , dStats ) { if ( sStats . isFile ( ) ) { var 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 ) ; } var pathInfo = path . parse ( destination ) ; var execCopy = function execCopy ( src , dest ) { fsExtra . copy ( src , dest , function ( err ) { if ( err ) reject ( err ) ; resolve ( ) ; } ) ; } ; if ( pathInfo . ext === '' ) { makeDir ( destination ) . then ( function ( mPath ) { execCopy ( command . source , destination + '/' + path . basename ( command . source ) ) ; } ) ; } else { execCopy ( command . source , destination ) ; } } else { var 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
               */