From 85ba9bfffba9bfd0b095cb766f72700d4c211e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 9 Sep 2020 22:31:43 +0200 Subject: Add "hugo mod npm pack" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit also introduces a convention where these common JS config files, including `package.hugo.json`, gets mounted into: ``` assets/_jsconfig ยด`` These files mapped to their real filename will be added to the environment when running PostCSS, Babel etc., so you can do `process.env.HUGO_FILE_TAILWIND_CONFIG_JS` to resolve the real filename. But do note that `assets` is a composite/union filesystem, so if your config file is not meant to be overridden, name them something specific. This commit also adds adds `workDir/node_modules` to `NODE_PATH` and `HUGO_WORKDIR` to the env when running the JS tools above. Fixes #7644 Fixes #7656 Fixes #7675 --- hugofs/files/classifier.go | 10 ++++++++++ hugofs/rootmapping_fs.go | 3 --- hugofs/walk_test.go | 8 -------- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'hugofs') diff --git a/hugofs/files/classifier.go b/hugofs/files/classifier.go index 5e26bbac0..35e416c8f 100644 --- a/hugofs/files/classifier.go +++ b/hugofs/files/classifier.go @@ -26,6 +26,13 @@ import ( "github.com/spf13/afero" ) +const ( + // The NPM package.json "template" file. + FilenamePackageHugoJSON = "package.hugo.json" + // The NPM package file. + FilenamePackageJSON = "package.json" +) + var ( // This should be the only list of valid extensions for content files. contentFileExtensions = []string{ @@ -163,9 +170,12 @@ const ( ComponentFolderI18n = "i18n" FolderResources = "resources" + FolderJSConfig = "_jsconfig" // Mounted below /assets with postcss.config.js etc. ) var ( + JsConfigFolderMountPrefix = filepath.Join(ComponentFolderAssets, FolderJSConfig) + ComponentFolders = []string{ ComponentFolderArchetypes, ComponentFolderStatic, diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go index ea3ef003e..2c4f0df52 100644 --- a/hugofs/rootmapping_fs.go +++ b/hugofs/rootmapping_fs.go @@ -42,9 +42,6 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) { (&rm).clean() fromBase := files.ResolveComponentFolder(rm.From) - if fromBase == "" { - panic("unrecognised component folder in" + rm.From) - } if len(rm.To) < 2 { panic(fmt.Sprintf("invalid root mapping; from/to: %s/%s", rm.From, rm.To)) diff --git a/hugofs/walk_test.go b/hugofs/walk_test.go index 0c08968c6..c38c6044f 100644 --- a/hugofs/walk_test.go +++ b/hugofs/walk_test.go @@ -21,8 +21,6 @@ import ( "strings" "testing" - "github.com/gohugoio/hugo/common/hugo" - "github.com/pkg/errors" "github.com/gohugoio/hugo/htesting" @@ -129,12 +127,6 @@ func TestWalkSymbolicLink(t *testing.T) { }) t.Run("BasePath Fs", func(t *testing.T) { - if hugo.GoMinorVersion() < 12 { - // https://github.com/golang/go/issues/30520 - // This is fixed in Go 1.13 and in the latest Go 1.12 - t.Skip("skip this for Go <= 1.11 due to a bug in Go's stdlib") - - } c := qt.New(t) docsFs := afero.NewBasePathFs(fs, docsDir) -- cgit v1.2.3