/*
Expand dirs/files to an array of kalabox-compose files options
328840
function(compose, project, opts) {

    // A project is required
    if (!project) {
      throw new VError('Need to give this composition a project name!');
    }

    // Kick off options
    var options = ['--project-name', project];

    // Get our array of compose files
    var files = parseComposeData(compose, project, opts);

    // Return our compose option
    return options.concat(files);

  }
1271127
function getdirFiles(dir, prefix = '') {
  dir = path.normalize(dir);
  if (!fs.existsSync(dir)) return [];
  const files = fs.readdirSync(dir);
  let result = [];
  files.forEach(item => {
    const currentDir = path.join(dir, item);
    const stat = fs.statSync(currentDir);
    if (stat.isFile()) {
      result.push(path.join(prefix, item));
    } else if (stat.isDirectory()) {
      const cFiles = getdirFiles(currentDir, path.join(prefix, item));
      result = result.concat(cFiles);
    }
  });
  return result;
}
745820
private void expandBoundingBox(BoundingBox boundingBox, List<LatLng> latLngs) {
        for (LatLng latLng : latLngs) {
            expandBoundingBox(boundingBox, latLng);
        }
    }
1277209
function explode(sources) {
		var json,
			res = [];
		sources.forEach(function(source) {
			switch (path.extname(source)) {
				case '.json':
					json = grunt.file.readJSON(source);
					res.push.apply(
						res,
						json.map(function(filepath) {
							return path.dirname(source) + '/' + filepath;
						})
					);
					break;
				case '.js':
					res.push(source);
					break;
			}
		});
		return res;
	}
737743
function arrayApi(input, opts, cb) {
    var fd = new FormData(), files = [];
    [].slice.call(input.files).forEach(function(file) {
      fd.append(opts.name, file, file.webkitRelativePath || file.name);
      files.push(file.webkitRelativePath || file.name);
    });
    cb(fd, files);
  }
509093
function expandWildcard (name, scripts) {
  const n = swapColonAndSlash(name)
  return Object.keys(scripts)
    .map(swapColonAndSlash)
    .filter(x => minimatch(x, n))
    .map(swapColonAndSlash)
}
418331
function(compose, project, opts) {

    // Default options
    var defaults = {
      force: true,
      volumes: true
    };

    // Get opts
    var options = (opts) ? _.merge(defaults, opts) : defaults;

    // Build the command and run it
    var cmd = buildCmd(compose, project, 'rm', options);
    return shCompose(cmd, {
      app: opts.app,
      mode: 'collect'
    });
  }
1007877
function expandGlobs(main, cwd) {
  if (!main) { return; }
  // expand each glob in main (coerce it to array first)
  var globs = [].concat(main).map(function(pattern) {
    return glob.sync(pattern, {cwd: cwd});
  });
  // flatten globs to single array
  return [].concat.apply([], globs);
}
1343557
function extend(dest, src) {
  for (var i in src) dest[i] = src[i];
  return dest;
}
705814
private function expandConfigDirectories()
    {
        $newPaths = [];
        foreach ($this->configDirectories as $filePath) {
            $newPaths[] = __DIR__ . '/../../../../../' . $filePath;
        }
        $this->configDirectories = $newPaths;
    }
301272
function (dir, filelist, extensions, ignore) {
    const files = fs.readdirSync(dir);
    filelist = filelist || [];
    files.forEach(function (file) {
        const ext = fileExtension(file);
        if (ignore.indexOf(ext) === -1) {
            if (fs.statSync(path.resolve(dir, file)).isDirectory()) {
                filelist = walkSync(path.join(dir, file, "/"), filelist, extensions, ignore);
            }
            else {
                if (extensions.indexOf(ext) !== -1) {
                    filelist.push(path.join(dir, file));
                }
            }
        }
    });
    return filelist;
}
82541
function expandAll() {
        var editor = EditorManager.getFocusedEditor();
        if (editor) {
            var cm = editor._codeMirror;
            CodeMirror.commands.unfoldAll(cm);
        }
    }
507674
function addFiles(sources, dest, options) {
      var opt = _.extend({}, defaultOptions, options || {});

      if(_.isString(sources)) {
        sources = [sources];
      }

      if(!inCwd(dest) || _.any(sources, function(src) {
        return !inCwd(src);
      })) {
        grunt.verbose.writeln('Ignore %s to %s: not in CWD.');
        return;
      }

      return addToQueueCopy(sources, dest, opt);
    }
861760
function( files, options, callback ) {
	if ( !Array.isArray( files ) ) {
		files = [files];
	}
	if ( typeof options === 'function' ) {
		callback = options;
		options = null;
	} else if ( typeof options === 'string' ) {
		options = { msg: options };
	}
	options = options || {};
	addExtraOptions( [ 'quiet', 'depth', 'msg' ], options );
	executeSvn( [ 'commit' ].concat( files ), options, callback );
}
110716
function addMaping(folder) {
	Object.defineProperties(folder, {
		// Return all enumerable properties
		_subfiles: {
			get: function () {
                return filter(folder, {type: ['file','directory']}, 'keys');
            }
		},
		// Return properties with _type === 'file'
		_files: {
			get: function () {
                return filter(folder, {type: 'file'}, 'keys');
			}
		},
		// Return properties with _type === 'directory'
		_folders: {
			get: function () {
                return filter(folder, {type: 'directory'}, 'keys');
			}
		},
        __filter: {
            value: function (opts, returnArray) {
                if(!opts.recursive) {
                    return filter(folder, opts, returnArray);
                }
                opts.recursive = false;
                if(!returnArray) {
                    return filter(folder, opts, returnArray);
                }
                return filterRecursive(folder, opts, returnArray);
            }
        },
        __clear: {
            value: function () {
                folder._subfiles.forEach(function (key) {
                    delete folder[key];
                });
            }
        },
		// Function for starting mapping from current folder with opts
		__map: {
			value: function (opts, callback) {
				if (typeof opts === 'function') {
					callback = opts;
					opts = {};
				}

				folder.__list(function (err, list) {
					if (err) {
						callback(err);
						return;
					}
					mapObjects(folder, list, function (err, map) {
						if (err) {
							callback(err);
							return;
						}
						var folders = transfer(folder, map, opts);
						var count = folders.length;

						if (!opts.recursive || count === 0) {
                            if(!opts.extend) {
                                callback(null, folder);
                                return;
                            }

                            extendComponents(folder, opts, callback);
							return;
						}

						var sent = false;
						folders.forEach(function (f) {
							f.__map(opts, function (err, fMap) {
								if (err) {
									if (!sent) {
										callback(err);
										sent = true;
									}
									return;
								}
                                if (!opts.simple) {
                                    transfer(folder, fMap, opts);
                                }
								if (--count === 0) {
                                    if(!opts.extend) {
                                        callback(null, folder);
                                        return;
                                    }
                                    extendComponents(folder, opts, callback);
								}
							});
						});
					});
				});
			}
		},
        __reMap: {
            value: function (callback) {
                folder.__clear();
                folder.__map(callback);
            }
        },
        __watchMap: {
            value: function (persistent, callback) {
                if(typeof persistent === 'function') {
                    callback = persistent;
                    persistent = false;
                }
                folder.__watchList(persistent, function (err, list) {
                    if(err) {
                        callback(err);
                        return;
                    }
                    folder.__reMap(callback);
                });
            }
        },
        __extend: {
            value: function (map) {
                return utils.extend(folder, map, true);
            }
        }
	});
}
1100518
function expandFiles(files, basePath) {
    var expandedFiles = [];
    files = files ? _.isArray(files) ? files : [files] : [];

    _.forEach(files, function(fileName) {
        expandedFiles = _.union(
            expandedFiles,
            glob.sync(path.join(basePath, fileName), { dot: true, nodir: true })
        );
    });

    return expandedFiles;
}
1199114
function addFiles (formData, files) {
    var file, arr, key, i = 0, filename;

    for (key in files) {
        if (files.hasOwnProperty(key) && files[key]) {

            if (files[key] instanceof Array) {
                arr = files[key];
                filename = getFilename(arr[i]) || null;

                for (i = 0; i < arr.length; i += 1) {
                    formData.append(key + '[' + i + ']', arr[i]);
                }
            } else {
                file = files[key];
                filename = getFilename(file) || null;
                formData.append(key, file, filename);
            }
        }
    }
}