cli: Output layers under subdirectory
This commit is contained in:
parent
2d36513e2c
commit
d80b2d3842
1 changed files with 6 additions and 2 deletions
8
main.go
8
main.go
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -323,7 +324,10 @@ func _render(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc
|
|||
}
|
||||
}
|
||||
|
||||
outputPath = layerOutputPath(outputPath, diagram)
|
||||
err = os.MkdirAll(filepath.Dir(outputPath), 0755)
|
||||
if err != nil {
|
||||
return svg, err
|
||||
}
|
||||
err = ms.WritePath(outputPath, out)
|
||||
if err != nil {
|
||||
return svg, err
|
||||
|
|
@ -340,7 +344,7 @@ func layerOutputPath(outputPath string, d *d2target.Diagram) string {
|
|||
}
|
||||
ext := filepath.Ext(outputPath)
|
||||
outputPath = strings.TrimSuffix(outputPath, ext)
|
||||
outputPath += "-" + d.Name
|
||||
outputPath += "/" + d.Name
|
||||
outputPath += ext
|
||||
return outputPath
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue