mirror of
https://github.com/go-task/task.git
synced 2025-11-25 22:32:55 +02:00
feat: decoding improvements (#2068)
* refactor: moved/simplified snippets into its own file with tests * refactor: move snippet to taskfile package * feat: support snippets with line/col = 0 * feat: functional options for snippets * feat: added option to hide snippet indicators * feat: store raw lines for length calculations * feat: add debug function for TaskfileDecodeError * fix: decode errors from commands * fix: schema for defer cmd calls * fix: linting issues * refactor: split var and vars into different files like other structures
This commit is contained in:
@@ -193,9 +193,14 @@ func (r *Reader) readNode(node Node) (*ast.Taskfile, error) {
|
||||
var tf ast.Taskfile
|
||||
if err := yaml.Unmarshal(b, &tf); err != nil {
|
||||
// Decode the taskfile and add the file info the any errors
|
||||
taskfileInvalidErr := &errors.TaskfileDecodeError{}
|
||||
if errors.As(err, &taskfileInvalidErr) {
|
||||
return nil, taskfileInvalidErr.WithFileInfo(node.Location(), b, 2)
|
||||
taskfileDecodeErr := &errors.TaskfileDecodeError{}
|
||||
if errors.As(err, &taskfileDecodeErr) {
|
||||
snippet := NewSnippet(b,
|
||||
SnippetWithLine(taskfileDecodeErr.Line),
|
||||
SnippetWithColumn(taskfileDecodeErr.Column),
|
||||
SnippetWithPadding(2),
|
||||
)
|
||||
return nil, taskfileDecodeErr.WithFileInfo(node.Location(), snippet.String())
|
||||
}
|
||||
return nil, &errors.TaskfileInvalidError{URI: filepathext.TryAbsToRel(node.Location()), Err: err}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user