mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 14:10:31 +03:00
modules/npm: Preserve the original package.json if it exists
Fixes #7690
This commit is contained in:
parent
cd830bb027
commit
214afe4c1b
3 changed files with 31 additions and 15 deletions
|
@ -18,6 +18,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hugio"
|
||||
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -51,7 +53,12 @@ func Pack(fs afero.Fs, fis []hugofs.FileMetaInfo) error {
|
|||
if err != nil {
|
||||
// Have a package.json?
|
||||
fi, err = fs.Stat(packageJSONName)
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
// Preserve the original in package.hugo.json.
|
||||
if err = hugio.CopyFile(fs, packageJSONName, files.FilenamePackageHugoJSON); err != nil {
|
||||
return errors.Wrap(err, "npm pack: failed to copy package file")
|
||||
}
|
||||
} else {
|
||||
// Create one.
|
||||
name := "project"
|
||||
// Use the Hugo site's folder name as the default name.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue