mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
9f12be54ee
commit
d8d6a25b57
1 changed files with 24 additions and 2 deletions
|
@ -194,6 +194,9 @@ func (c *Client) Vendor() error {
|
||||||
if err := c.rmVendorDir(vendorDir); err != nil {
|
if err := c.rmVendorDir(vendorDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := c.fs.MkdirAll(vendorDir, 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Write the modules list to modules.txt.
|
// Write the modules list to modules.txt.
|
||||||
//
|
//
|
||||||
|
@ -228,9 +231,28 @@ func (c *Client) Vendor() error {
|
||||||
dir := t.Dir()
|
dir := t.Dir()
|
||||||
|
|
||||||
for _, mount := range t.Mounts() {
|
for _, mount := range t.Mounts() {
|
||||||
if err := hugio.CopyDir(c.fs, filepath.Join(dir, mount.Source), filepath.Join(vendorDir, t.Path(), mount.Source), nil); err != nil {
|
sourceFilename := filepath.Join(dir, mount.Source)
|
||||||
|
targetFilename := filepath.Join(vendorDir, t.Path(), mount.Source)
|
||||||
|
fi, err := c.fs.Stat(sourceFilename)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to vendor module")
|
||||||
|
}
|
||||||
|
|
||||||
|
if fi.IsDir() {
|
||||||
|
if err := hugio.CopyDir(c.fs, sourceFilename, targetFilename, nil); err != nil {
|
||||||
return errors.Wrap(err, "failed to copy module to vendor dir")
|
return errors.Wrap(err, "failed to copy module to vendor dir")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
targetDir := filepath.Dir(targetFilename)
|
||||||
|
|
||||||
|
if err := c.fs.MkdirAll(targetDir, 0755); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to make target dir")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := hugio.CopyFile(c.fs, sourceFilename, targetFilename); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to copy module file to vendor")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include the resource cache if present.
|
// Include the resource cache if present.
|
||||||
|
|
Loading…
Reference in a new issue