cake-build / cake-build/cake

GetFiles() using Glob curly braces requires preceeding characters

Open
#2,667 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
3h 37m
Merged PRs (30d)
21

Description

### What You Are Seeing?
Can't use glob curly braces as the first logical expression of a subfolder when copying files.
```
var directory = Directory("temp");
CopyFiles("Directory.Name/App/**/{*.js,*.js.map}", directory, true);
```
Fails with error
```
Error: One or more errors occurred.
parsing "^(*.js|*.js.map)$" - Quantifier {x,y} following nothing.
```
However the following expression works
```
var directory = Directory("temp");
CopyFiles("Directory.Name/App/**/*{.js,.js.map}", directory, true);
```

### What is Expected?
Files should be able to be copied in the above stated failed expression.

### What version of Cake are you using?
0.35.0
### Are you running on a 32 or 64 bit system?
64
### What environment are you running on? Windows? Linux? Mac?
Windows
### Are you running on a CI Server? If so, which one?
No
### How Did You Get This To Happen? (Steps to Reproduce)
See above
### Output Log
~~~sh
Error: System.AggregateException: One or more errors occurred. ---> System.ArgumentException: parsing "^(*.js|*.js.map)$" - Quantifier {x,y} following nothing.
at System.Text.RegularExpressions.RegexParser.ScanRegex()
at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options)
at Cake.Core.IO.Globbing.Nodes.PathNode.CreateRegex(List`1 tokens, RegexOptions options)
at Cake.Core.IO.Globbing.Nodes.PathNode..ctor(List`1 tokens, RegexOptions options)
at Cake.Core.IO.Globbing.GlobParser.ParseNode(GlobParserContext context)
at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
at Cake.Core.IO.Globbing.GlobParser.Parse(String pattern, GlobberSettings settings)
at Cake.Core.IO.Globber.Match(String pattern, GlobberSettings settings)
at Cake.Common.IO.GlobbingAliases.GetFiles(ICakeContext context, String pattern)
at Cake.Common.IO.FileCopier.CopyFiles(ICakeContext context, String pattern, DirectoryPath targetDirectoryPath, Boolean preserverFolderStructure)
at Submission#0.CopyFiles(String pattern, DirectoryPath targetDirectoryPath, Boolean preserveFolderStructure)
at Submission#0.<>b__0_22()
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass24_0.b__0(ICakeContext x)
at Cake.Core.CakeTask.d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.d__21.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
---> (Inner Exception #0) System.ArgumentException: parsing "^(*.js|*.js.map)$" - Quantifier {x,y} following nothing.
at System.Text.RegularExpressions.RegexParser.ScanRegex()
at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options)
at Cake.Core.IO.Globbing.Nodes.PathNode.CreateRegex(List`1 tokens, RegexOptions options)
at Cake.Core.IO.Globbing.Nodes.PathNode..ctor(List`1 tokens, RegexOptions options)
at Cake.Core.IO.Globbing.GlobParser.ParseNode(GlobParserContext context)
at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
at Cake.Core.IO.Globbing.GlobParser.Parse(String pattern, GlobberSettings settings)
at Cake.Core.IO.Globber.Match(String pattern, GlobberSettings settings)
at Cake.Common.IO.GlobbingAliases.GetFiles(ICakeContext context, String pattern)
at Cake.Common.IO.FileCopier.CopyFiles(ICakeContext context, String pattern, DirectoryPath targetDirectoryPath, Boolean preserverFolderStructure)
at Submission#0.CopyFiles(String pattern, DirectoryPath targetDirectoryPath, Boolean preserveFolderStructure)
at Submission#0.<>b__0_22()
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass24_0.b__0(ICakeContext x)
at Cake.Core.CakeTask.d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.d__21.MoveNext()<---
~~~

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failing GetFiles/CopyFiles pattern, then inspect Cake.Core.IO.Globbing.Nodes.PathNode and GlobParser using the stack trace. The fix is complete when a leading curly-brace expression such as {*.js,*.js.map} no longer produces the regex parsing error and the expected files are copied.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.