aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/npm
diff options
context:
space:
mode:
authorShohei Ueda <[email protected]>2021-05-09 07:20:28 +0900
committerGitHub <[email protected]>2021-05-09 00:20:28 +0200
commit504c78da4b5020e1fd13a1195ad38a9e85f8289a (patch)
treec0f43234334f98f2c6942af8d1f5de90e7096d04 /modules/npm
parentb660ea8d545d6ba5479dd28a670044d57e5d196f (diff)
downloadhugo-504c78da4b5020e1fd13a1195ad38a9e85f8289a.tar.gz
hugo-504c78da4b5020e1fd13a1195ad38a9e85f8289a.zip
modules/npm: Change SetEscapeHTML to false
Closes #8512
Diffstat (limited to 'modules/npm')
-rw-r--r--modules/npm/package_builder.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/npm/package_builder.go b/modules/npm/package_builder.go
index f407a92bd..fe5d19832 100644
--- a/modules/npm/package_builder.go
+++ b/modules/npm/package_builder.go
@@ -14,9 +14,11 @@
package npm
import (
+ "bytes"
"encoding/json"
"fmt"
"io"
+ "strings"
"github.com/gohugoio/hugo/common/hugio"
@@ -129,12 +131,15 @@ func Pack(fs afero.Fs, fis []hugofs.FileMetaInfo) error {
b.originalPackageJSON["comments"] = commentsm
// Write it out to the project package.json
- packageJSONData, err := json.MarshalIndent(b.originalPackageJSON, "", " ")
- if err != nil {
+ packageJSONData := new(bytes.Buffer)
+ encoder := json.NewEncoder(packageJSONData)
+ encoder.SetEscapeHTML(false)
+ encoder.SetIndent("", strings.Repeat(" ", 2))
+ if err := encoder.Encode(b.originalPackageJSON); err != nil {
return errors.Wrap(err, "npm pack: failed to marshal JSON")
}
- if err := afero.WriteFile(fs, packageJSONName, packageJSONData, 0666); err != nil {
+ if err := afero.WriteFile(fs, packageJSONName, packageJSONData.Bytes(), 0666); err != nil {
return errors.Wrap(err, "npm pack: failed to write package.json")
}