/// <summary>
        /// Enumerate all the PowerShell (ps1, psm1, psd1) files in the workspace in a recursive manner.
        /// </summary>
        /// <returns>An enumerator over the PowerShell files found in the workspace.</returns>
        public IEnumerable <string> EnumeratePSFiles(
            string[] excludeGlobs,
            string[] includeGlobs,
            int maxDepth,
            bool ignoreReparsePoints
            )
        {
            if (WorkspacePath == null || !Directory.Exists(WorkspacePath))
            {
                yield break;
            }

            var matcher = new Matcher();

            foreach (string pattern in includeGlobs)
            {
                matcher.AddInclude(pattern);
            }
            foreach (string pattern in excludeGlobs)
            {
                matcher.AddExclude(pattern);
            }

            var fsFactory = new WorkspaceFileSystemWrapperFactory(
                WorkspacePath,
                maxDepth,
                VersionUtils.IsNetCore ? s_psFileExtensionsCoreFramework : s_psFileExtensionsFullFramework,
                ignoreReparsePoints,
                logger
                );
            var fileMatchResult = matcher.Execute(fsFactory.RootDirectory);

            foreach (FilePatternMatch item in fileMatchResult.Files)
            {
                // item.Path always contains forward slashes in paths when it should be backslashes on Windows.
                // Since we're returning strings here, it's important to use the correct directory separator.
                var path = VersionUtils.IsWindows ? item.Path.Replace('/', Path.DirectorySeparatorChar) : item.Path;
                yield return(Path.Combine(WorkspacePath, path));
            }
        }
Пример #2
0
        /// <summary>
        /// Enumerate all the PowerShell (ps1, psm1, psd1) files in the workspace in a recursive manner.
        /// </summary>
        /// <returns>An enumerator over the PowerShell files found in the workspace.</returns>
        public IEnumerable <string> EnumeratePSFiles(
            string[] excludeGlobs,
            string[] includeGlobs,
            int maxDepth,
            bool ignoreReparsePoints
            )
        {
            if (WorkspacePath == null || !Directory.Exists(WorkspacePath))
            {
                yield break;
            }

            var matcher = new Matcher();

            foreach (string pattern in includeGlobs)
            {
                matcher.AddInclude(pattern);
            }
            foreach (string pattern in excludeGlobs)
            {
                matcher.AddExclude(pattern);
            }

            var fsFactory = new WorkspaceFileSystemWrapperFactory(
                WorkspacePath,
                maxDepth,
                VersionUtils.IsNetCore ? s_psFileExtensionsCoreFramework : s_psFileExtensionsFullFramework,
                ignoreReparsePoints,
                logger
                );
            var fileMatchResult = matcher.Execute(fsFactory.RootDirectory);

            foreach (FilePatternMatch item in fileMatchResult.Files)
            {
                yield return(Path.Combine(WorkspacePath, item.Path));
            }
        }