hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

mod_npm.go (2012B)

    1 // Copyright 2020 The Hugo Authors. All rights reserved.
    2 //
    3 // Licensed under the Apache License, Version 2.0 (the "License");
    4 // you may not use this file except in compliance with the License.
    5 // You may obtain a copy of the License at
    6 // http://www.apache.org/licenses/LICENSE-2.0
    7 //
    8 // Unless required by applicable law or agreed to in writing, software
    9 // distributed under the License is distributed on an "AS IS" BASIS,
   10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   11 // See the License for the specific language governing permissions and
   12 // limitations under the License.
   13 
   14 package commands
   15 
   16 import (
   17 	"github.com/gohugoio/hugo/hugolib"
   18 	"github.com/gohugoio/hugo/modules/npm"
   19 	"github.com/spf13/cobra"
   20 )
   21 
   22 func newModNPMCmd(c *modCmd) *cobra.Command {
   23 	cmd := &cobra.Command{
   24 		Use:   "npm",
   25 		Short: "Various npm helpers.",
   26 		Long:  `Various npm (Node package manager) helpers.`,
   27 		RunE: func(cmd *cobra.Command, args []string) error {
   28 			return c.withHugo(func(h *hugolib.HugoSites) error {
   29 				return nil
   30 			})
   31 		},
   32 	}
   33 
   34 	cmd.AddCommand(&cobra.Command{
   35 		Use:   "pack",
   36 		Short: "Experimental: Prepares and writes a composite package.json file for your project.",
   37 		Long: `Prepares and writes a composite package.json file for your project.
   38 
   39 On first run it creates a "package.hugo.json" in the project root if not already there. This file will be used as a template file
   40 with the base dependency set. 
   41 
   42 This set will be merged with all "package.hugo.json" files found in the dependency tree, picking the version closest to the project.
   43 
   44 This command is marked as 'Experimental'. We think it's a great idea, so it's not likely to be
   45 removed from Hugo, but we need to test this out in "real life" to get a feel of it,
   46 so this may/will change in future versions of Hugo.
   47 `,
   48 		RunE: func(cmd *cobra.Command, args []string) error {
   49 			return c.withHugo(func(h *hugolib.HugoSites) error {
   50 				return npm.Pack(h.BaseFs.SourceFs, h.BaseFs.Assets.Dirs)
   51 			})
   52 		},
   53 	})
   54 
   55 	return cmd
   56 }