File tree Expand file tree Collapse file tree
website/src/docs/reference Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ func init() {
3434 "IsSH" : IsSH , // Deprecated
3535 "joinPath" : filepath .Join ,
3636 "relPath" : filepath .Rel ,
37+ "absPath" : filepath .Abs ,
3738 "merge" : merge ,
3839 "spew" : spew .Sdump ,
3940 "fromYaml" : fromYaml ,
Original file line number Diff line number Diff line change @@ -2601,6 +2601,27 @@ func TestSplitArgs(t *testing.T) {
26012601 assert .Equal (t , "3\n " , buff .String ())
26022602}
26032603
2604+ func TestAbsPath (t * testing.T ) {
2605+ t .Parallel ()
2606+
2607+ var buff bytes.Buffer
2608+ e := task .NewExecutor (
2609+ task .WithDir ("testdata/abs_path" ),
2610+ task .WithStdout (& buff ),
2611+ task .WithStderr (& buff ),
2612+ task .WithSilent (true ),
2613+ )
2614+ require .NoError (t , e .Setup ())
2615+
2616+ err := e .Run (t .Context (), & task.Call {Task : "default" })
2617+ require .NoError (t , err )
2618+
2619+ cwd , err := os .Getwd ()
2620+ require .NoError (t , err )
2621+ expected := filepath .Join (cwd , "bar" ) + "\n "
2622+ assert .Equal (t , expected , buff .String ())
2623+ }
2624+
26042625func TestSingleCmdDep (t * testing.T ) {
26052626 t .Parallel ()
26062627
Original file line number Diff line number Diff line change 1+ version : ' 3'
2+
3+ tasks :
4+ default :
5+ cmds :
6+ - cmd : echo '{{absPath "foo/../bar"}}'
Original file line number Diff line number Diff line change @@ -617,6 +617,7 @@ tasks:
617617 - echo "{{.WIN_PATH | fromSlash}}" # Convert to OS-specific slashes
618618 - echo "{{joinPath .OUTPUT_DIR .BINARY_NAME}}" # Join path elements
619619 - echo "Relative {{relPath .ROOT_DIR .TASKFILE_DIR}}" # Get relative path
620+ - echo '{{absPath "../sibling"}}' # Resolve to an absolute path
620621` ` `
621622
622623# ## Data Structure Functions
You can’t perform that action at this time.
0 commit comments