diff --git a/commands/commandeer.go b/commands/commandeer.go index 3f9f02d2319..7a5c8bc8551 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -538,6 +538,7 @@ Complete documentation is available at https://gohugo.io/.` cmd.PersistentFlags().StringP("themesDir", "", "", "filesystem path to themes directory") _ = cmd.MarkFlagDirname("themesDir") cmd.PersistentFlags().StringP("ignoreVendorPaths", "", "", "ignores any _vendor for module paths matching the given Glob pattern") + cmd.PersistentFlags().BoolP("noBuildLock", "", false, "don't create .hugo_build.lock file") _ = cmd.RegisterFlagCompletionFunc("ignoreVendorPaths", cobra.NoFileCompletions) cmd.PersistentFlags().String("clock", "", "set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00") _ = cmd.RegisterFlagCompletionFunc("clock", cobra.NoFileCompletions) @@ -593,7 +594,6 @@ func applyLocalFlagsBuild(cmd *cobra.Command, r *rootCommand) { cmd.Flags().BoolVar(&r.forceSyncStatic, "forceSyncStatic", false, "copy all files when static is changed.") cmd.Flags().BoolP("noTimes", "", false, "don't sync modification time of files") cmd.Flags().BoolP("noChmod", "", false, "don't sync permission mode of files") - cmd.Flags().BoolP("noBuildLock", "", false, "don't create .hugo_build.lock file") cmd.Flags().BoolP("printI18nWarnings", "", false, "print missing translations") cmd.Flags().BoolP("printPathWarnings", "", false, "print warnings on duplicate target paths etc.") cmd.Flags().BoolP("printUnusedTemplates", "", false, "print warnings on unused templates.") diff --git a/create/content.go b/create/content.go index f7c343d424e..db07720ade6 100644 --- a/create/content.go +++ b/create/content.go @@ -82,11 +82,13 @@ func NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error b.setArcheTypeFilenameToUse(ext) withBuildLock := func() (string, error) { - unlock, err := h.BaseFs.LockBuild() - if err != nil { - return "", fmt.Errorf("failed to acquire a build lock: %s", err) + if !h.Configs.Base.NoBuildLock { + unlock, err := h.BaseFs.LockBuild() + if err != nil { + return "", fmt.Errorf("failed to acquire a build lock: %s", err) + } + defer unlock() } - defer unlock() if b.isDir { return "", b.buildDir()