Concat many source to dest

@param {Array} sources
Array of source path

@param {String} dest
Destination path

@param {Object} options
Transfo options object

@return {Promise} TODO
165777
function addToQueueConcat(sources, dest, options) {
      queueConcat.push({
        src:     sources,
        dest:    dest,
        options: _.extend({}, defaultOptions, options || {})
      });
    }
1079824
function Consign(options) {
  options = options || {};

  this._options = {
    cwd: process.cwd(),
    locale: 'en-us',
    logger: console,
    verbose: true,
    extensions: [],
    loggingType: 'info'
  };

  this._files = [];
  this._object = {};
  this._extensions = this._options.extensions.concat(['.js', '.json', '.node']);
  this._lastOperation = 'include';

  if (options.extensions) {
    this._extensions.concat(options.extensions);
  }

  for (var o in options) {
    this._options[o] = options[o];
  }

  this._ = require(path.join(__dirname, '..', 'locale', this._options.locale));

  this._log([pack.name, 'v' + pack.version, this._['Initialized in'], this._options.cwd]);

  return this;
}
742318
function transformVariables(source, dest) {
        var xformed, arrayVals;

        if (dest === undefined) {
            if (source.uploaderType !== "basic") {
                xformed = { element: $el[0] };
            }
            else {
                xformed = {};
            }
        }
        else {
            xformed = dest;
        }

        $.each(source, function(prop, val) {
            if ($.inArray(prop, pluginOptions) >= 0) {
                pluginOption(prop, val);
            }
            else if (val instanceof $) {
                xformed[prop] = val[0];
            }
            else if ($.isPlainObject(val)) {
                xformed[prop] = {};
                transformVariables(val, xformed[prop]);
            }
            else if ($.isArray(val)) {
                arrayVals = [];
                $.each(val, function(idx, arrayVal) {
                    var arrayObjDest = {};

                    if (arrayVal instanceof $) {
                        $.merge(arrayVals, arrayVal);
                    }
                    else if ($.isPlainObject(arrayVal)) {
                        transformVariables(arrayVal, arrayObjDest);
                        arrayVals.push(arrayObjDest);
                    }
                    else {
                        arrayVals.push(arrayVal);
                    }
                });
                xformed[prop] = arrayVals;
            }
            else {
                xformed[prop] = val;
            }
        });

        if (dest === undefined) {
            return xformed;
        }
    }
727952
function copyDirAsync(src, dest) {
  if (fs.lstatSync(src).isDirectory()) {
    const files = fs.readdirSync(src);
    files.forEach((file) => {
      const curSource = path.join(src, file);
      const curDest = path.join(dest, file);
      if (fs.lstatSync(curSource).isDirectory()) {
        if (!fs.existsSync(curDest)) {
          createDir(curDest);
        }
        copyDirAsync(curSource, curDest);
      } else {
        fs.copyAsync(curSource, curDest);
      }
    });
  }
}
1171719
function convert(files) {
    var converted = []
    files.forEach(function(file) {
      // We need originals as the destinations may not yet exist
      file = file.orig
      var dest = file.dest

      // Use destination for source if no source is available
      if (!file.src.length) {
        converted.push({
          src: dest,
          dest: dest
        })
        return
      }

      file.src.forEach(function(source) {
        converted.push({
          src: source,
          dest: dest
        })
      })
    })
    return converted
  }
1029799
function rewriteDest(dest, src, opts) {
  dest = utils.resolve(dest);
  if (opts.destBase) {
    dest = path.join(opts.destBase, dest);
  }
  if (opts.extDot || opts.hasOwnProperty('ext')) {
    dest = rewriteExt(dest, opts);
  }
  if (typeof opts.rename === 'function') {
    return opts.rename(dest, src, opts);
  }
  return dest;
}
203674
function extend(dest, source){
    for (var key in source)
      dest[key] = source[key];

    return dest;
  }
1250028
function concat(a,o,dest,p,replacement){

	if(a.length > 0) {

		var content = '';
		// console.log(a);
		// var a = a.reverse();
		var rel = path.dirname(path.relative(dest,p));
		fs.writeFileSync(o,'',{
			encoding:'utf8'
		});
		a.forEach(function(v){
			// var ap = path.resolve(pwd,dest,v);
			var ap = path.resolve(pwd,dest,rel,v);
			if(replacement){
				ap = ap.replace(replacement.from,replacement.to);
			}
			if(!fs.existsSync(ap)){
				return;
			}
			var str = read(ap).toString('utf8');
			str += '\n';
			fs.appendFileSync(o,str);
		});
		return read(o).toString('utf8');

	} else {
		return null;
	}

}
221151
function (destPath, srcPaths, options) {
    let stream,
        b,
        finalPaths = [];
    return new Promise(function (resolve, reject) {
        _.each(srcPaths, function (path) {
            // deal with file globs
            if (glob.hasMagic(path)) {
                glob.sync(path).forEach((p) => {
                    p = utils.scopePaths(p);
                    finalPaths.push(p);
                });
            } else {
                path = utils.scopePaths(path);
                finalPaths.push(path);
            }
        });

        // add required parameters for watchify
        options.cache = {};
        options.packageCache = {};

        options.debug = options.watch;

        b = browserify(options);

        b.transform(envify({
            _: 'purge',
            NODE_ENV: options.env
        }), {global: true});

        // must add each path individual unfortunately.
        finalPaths.forEach(function (path) {
            b.add(path);
        });

        options.ignore.forEach((file) => {
            b.ignore(file);
        });
        options.exclude.forEach((file) => {
            b.exclude(file);
        });

        // require global files
        _.each(options.requires, function (path, id) {
            // options.requires can be an array of strings or an object
            id = typeof id == "string" ? id : path;
            b.require(path, {expose: id});
        });

        if (options.watch) {
            b.plugin(watchify);
            // re-bundle when updated
            b.on('update', function () {
                console.log('file updated!');
                b.bundle();
            });
        }


        b.on('bundle', function (stream) {
            console.log('browserifying bundle...');
            writeBrowserifyBundleStreamToFile(stream, destPath)
                .then(function () {
                    console.log('done browserifying bundle!');
                    resolve();
                })
                .catch(function (e) {
                    console.log('browserifying failed');
                    console.log(e);
                    reject(e);
                });
        });

        stream = b.bundle();

    }.bind(this));
}
802856
function mapSources (sourceMap, mapCallback) {
  let chain = Promise.resolve()
  function pushChain (path, index, arr) {
    chain = chain
      .then(() => mapCallback(path))
      .then(replacement => {
        arr[index] = replacement || path
      })
  }
  if (sourceMap.sources) {
    sourceMap.sources.forEach(pushChain)
  }
  if (sourceMap.sections) {
    sourceMap.sections.forEach(section => {
      if (section.map && section.map.sources) {
        section.map.sources.forEach(pushChain)
      }
    })
  }
  return chain.then(() => sourceMap)
}
527126
function(sources){
    var exists = this.sourceValues_.map(function(sourceInfo){
      return sourceInfo.source;
    });
    var inserted = [];
    var deleted = [];
    var delta;

    if (!sources)
      sources = [];

    this.sourceDelta_ = {
      inserted: inserted,
      deleted: deleted
    };

    for (var i = 0; i < sources.length; i++)
    {
      var source = sources[i];
      if (!arrayRemove(exists, source))
        this.addSource(source);
    }

    exists.forEach(this.removeSource, this);

    this.sourceDelta_ = null;
    if (delta = getDelta(inserted, deleted))
      this.emit_sourcesChanged(delta);

    return delta;
  }
1106874
function multipart (req, options) {
  const result = {}
  return new Promise((resolve, reject) => {
    var form = new Busboy({ headers: req.headers })
    form.on('file', function(fieldname, file, filename, encoding, mimetype) {
      const value = result[fieldname]
      const duplex = new stream.Readable()
      duplex.filename = filename
      duplex.encoding = encoding
      duplex.mimetype = mimetype
      duplex._read = () => {}
      result[fieldname] =  value
        ? [].concat(value, duplex)
        : duplex
      file.on('data', data => duplex.push(data))
      file.on('end', () => duplex.push(null))
    });
    form.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
      const value = result[fieldname]
      result[fieldname] = value
        ? [].concat(value, val)
        : val
    });
    form.on('finish', () => resolve(result))
    req.pipe(form)
  })
}
603171
@Override
  public void concat(Path trg, Path[] psrcs) throws IOException {
    logger.atFine().log("GHFS.concat: %s, %s", trg, lazy(() -> Arrays.toString(psrcs)));

    checkArgument(psrcs.length > 0, "psrcs must have at least one source");

    URI trgPath = getGcsPath(trg);
    List<URI> srcPaths = Arrays.stream(psrcs).map(this::getGcsPath).collect(toImmutableList());

    checkArgument(!srcPaths.contains(trgPath), "target must not be contained in sources");

    List<List<URI>> partitions =
        Lists.partition(srcPaths, GoogleCloudStorage.MAX_COMPOSE_OBJECTS - 1);
    logger.atFine().log("GHFS.concat: %s, %d partitions", trg, partitions.size());
    for (List<URI> partition : partitions) {
      // We need to include the target in the list of sources to compose since
      // the GCS FS compose operation will overwrite the target, whereas the Hadoop
      // concat operation appends to the target.
      List<URI> sources = Lists.newArrayList(trgPath);
      sources.addAll(partition);
      logger.atFine().log("GHFS.concat compose: %s, %s", trgPath, sources);
      getGcsFs().compose(sources, trgPath, CreateFileOptions.DEFAULT_CONTENT_TYPE);
    }
    logger.atFine().log("GHFS.concat:=> ");
  }
49669
async function mergeSignatures(source, dest, attr, checkFn) {
  source = source[attr];
  if (source) {
    if (!dest[attr].length) {
      dest[attr] = source;
    } else {
      await Promise.all(source.map(async function(sourceSig) {
        if (!sourceSig.isExpired() && (!checkFn || await checkFn(sourceSig)) &&
            !dest[attr].some(function(destSig) {
              return util.equalsUint8Array(destSig.signature, sourceSig.signature);
            })) {
          dest[attr].push(sourceSig);
        }
      }));
    }
  }
}
1116664
private static String js_concat(String target, Object[] args) {
        int N = args.length;
        if (N == 0) { return target; }
        else if (N == 1) {
            String arg = ScriptRuntime.toString(args[0]);
            return target.concat(arg);
        }

        // Find total capacity for the final string to avoid unnecessary
        // re-allocations in StringBuilder
        int size = target.length();
        String[] argsAsStrings = new String[N];
        for (int i = 0; i != N; ++i) {
            String s = ScriptRuntime.toString(args[i]);
            argsAsStrings[i] = s;
            size += s.length();
        }

        StringBuilder result = new StringBuilder(size);
        result.append(target);
        for (int i = 0; i != N; ++i) {
            result.append(argsAsStrings[i]);
        }
        return result.toString();
    }
510716
public static function CopyFiles($source,$dest){
        File::mkfolders($dest);
        $folder = opendir($source);
        while($file = readdir($folder)){
            if ($file == '.' || $file == '..') continue;

            if(is_dir($source.'/'.$file)){
                mkdir($dest.'/'.$file,0777);
                $this->CopyFiles($source.'/'.$file,$dest.'/'.$file);
            }else copy($source.'/'.$file,$dest.'/'.$file);
        }
        closedir($folder);
        return 1;
    }
193406
function concatStreams(array) {
  var concat = new stream.PassThrough();

  function pipe(i) {
    if (i < array.length - 1) {
      array[i].pipe(concat, {end: false});
      array[i].on('end', function () { pipe(i + 1) });
    } else {
      array[i].pipe(concat);
    }
  }
  if (array.length > 0) {
    pipe(0);
  }

  return concat;
}