index.js
function searchPathsRec(thisPath, pathsToIgnore) {
		const subLogPrefix = logPrefix + 'searchPathsRec() - ';

		let result = [];
		let thisPaths;

		if (! pathsToIgnore) pathsToIgnore = [];

		try {
			if (that.fs.existsSync(thisPath + '/' + target) && result.indexOf(path.normalize(thisPath + '/' + target)) === - 1 && pathsToIgnore.indexOf(thisPath) === - 1) {
				result.push(path.normalize(thisPath + '/' + target));
			}

			if (! that.fs.existsSync(thisPath)) {
				return result;
			}

			thisPaths	= that.fs.readdirSync(thisPath);
		} catch (err) {
			that.log.error(subLogPrefix + 'throwed fs error: ' + err.message);

			return result;
		}

		for (let i = 0; thisPaths[i] !==  undefined; i ++) {
			try {
				const	subStat	= that.fs.statSync(thisPath + '/' + thisPaths[i]);

				if (subStat.isDirectory()) {
					if (thisPaths[i] !== target && pathsToIgnore.indexOf(thisPaths[i]) === - 1) {
						// If we've found a target dir, we do not wish to scan it
						result	= result.concat(searchPathsRec(thisPath + '/' + thisPaths[i], pathsToIgnore));
					}
				}
			} catch (err) {
				that.log.error(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message);
			}
		}

		return result;
	}
function searchPathsRec(thisPath, pathsToIgnore) {
		const subLogPrefix = logPrefix + 'searchPathsRec() - ';

		let result = [];
		let thisPaths;

		if (! pathsToIgnore) pathsToIgnore = [];

		try {
			if (that.fs.existsSync(thisPath + '/' + target) && result.indexOf(path.normalize(thisPath + '/' + target)) === - 1 && pathsToIgnore.indexOf(thisPath) === - 1) {
				result.push(path.normalize(thisPath + '/' + target));
			}

			if (! that.fs.existsSync(thisPath)) {
				return result;
			}

			thisPaths	= that.fs.readdirSync(thisPath);
		} catch (err) {
			that.log.error(subLogPrefix + 'throwed fs error: ' + err.message);

			return result;
		}

		for (let i = 0; thisPaths[i] !==  undefined; i ++) {
			try {
				const	subStat	= that.fs.statSync(thisPath + '/' + thisPaths[i]);

				if (subStat.isDirectory()) {
					if (thisPaths[i] !== target && pathsToIgnore.indexOf(thisPaths[i]) === - 1) {
						// If we've found a target dir, we do not wish to scan it
						result	= result.concat(searchPathsRec(thisPath + '/' + thisPaths[i], pathsToIgnore));
					}
				}
			} catch (err) {
				that.log.error(subLogPrefix + 'Could not read "' + thisPaths[i] + '": ' + err.message);
			}
		}

		return result;
	}
function searchPathsRec ( thisPath , pathsToIgnore ) { const subLogPrefix = logPrefix + 'searchPathsRec() - ' ; let result = [ ] ; let thisPaths ; if ( ! pathsToIgnore ) pathsToIgnore = [ ] ; try { if ( that . fs . existsSync ( thisPath + '/' + target ) && result . indexOf ( path . normalize ( thisPath + '/' + target ) ) === - 1 && pathsToIgnore . indexOf ( thisPath ) === - 1 ) { result . push ( path . normalize ( thisPath + '/' + target ) ) ; } if ( ! that . fs . existsSync ( thisPath ) ) { return result ; } thisPaths = that . fs . readdirSync ( thisPath ) ; } catch ( err ) { that . log . error ( subLogPrefix + 'throwed fs error: ' + err . message ) ; return result ; } for ( let i = 0 ; thisPaths [ i ] !== undefined ; i ++ ) { try { const subStat = that . fs . statSync ( thisPath + '/' + thisPaths [ i ] ) ; if ( subStat . isDirectory ( ) ) { if ( thisPaths [ i ] !== target && pathsToIgnore . indexOf ( thisPaths [ i ] ) === - 1 ) { // If we've found a target dir, we do not wish to scan it result = result . concat ( searchPathsRec ( thisPath + '/' + thisPaths [ i ] , pathsToIgnore ) ) ; } } } catch ( err ) { that . log . error ( subLogPrefix + 'Could not read "' + thisPaths [ i ] + '": ' + err . message ) ; } } return result ; }
Search for paths recursively

@param   {str} thisPath      - the path to search for
@param   {arr} pathsToIgnore - array of paths to ignore
@returns {str}               - absolute path
Search for paths recursively