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"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"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)
|
err = ms.WritePath(outputPath, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return svg, err
|
return svg, err
|
||||||
|
|
@ -340,7 +344,7 @@ func layerOutputPath(outputPath string, d *d2target.Diagram) string {
|
||||||
}
|
}
|
||||||
ext := filepath.Ext(outputPath)
|
ext := filepath.Ext(outputPath)
|
||||||
outputPath = strings.TrimSuffix(outputPath, ext)
|
outputPath = strings.TrimSuffix(outputPath, ext)
|
||||||
outputPath += "-" + d.Name
|
outputPath += "/" + d.Name
|
||||||
outputPath += ext
|
outputPath += ext
|
||||||
return outputPath
|
return outputPath
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue