/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

/**
 * Returns an array containing files to process by Umberto based on the configuration passed to the building task.
 *
 * If the `--skip-guides` option was passed, only `index.md` and API docs index files will be processed.
 *
 * If the `--guides` contains name of guides to process, the specified files will be parsed.
 *
 * Otherwise, the filtering mechanism is disabled, and all files will be built.
 *
 * @param {Array.<String>} guides
 * @param {Boolean} skipGuides
 * @return {nArray.<String>|null}
 */
module.exports = function getFilePatternsToProcess( { guides, skipGuides } ) {
	// When called with `--skip-guides`.
	if ( skipGuides ) {
		return [
			// Process all `index.md` files to avoid issues with navigation over simplified version of the documentation.
			'index.md',

			// Process all `api/*.md` files as they describe packages and are part of API docs.
			'api/*.md'
		];
	}

	// When called with `--guides`.
	if ( guides.length ) {
		return [
			// Process all `index.md` files to avoid issues with navigation over simplified version of the documentation.
			'index.md',
			...guides
		];
	}

	// When called without guides filtering.
	return null;
};
