Skip to content

Commit 2a7bb1c

Browse files
committed
create: Respect --noBuildLock in hugo new
1 parent b7b49fb commit 2a7bb1c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

commands/commandeer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ Complete documentation is available at https://gohugo.io/.`
538538
cmd.PersistentFlags().StringP("themesDir", "", "", "filesystem path to themes directory")
539539
_ = cmd.MarkFlagDirname("themesDir")
540540
cmd.PersistentFlags().StringP("ignoreVendorPaths", "", "", "ignores any _vendor for module paths matching the given Glob pattern")
541+
cmd.PersistentFlags().BoolP("noBuildLock", "", false, "don't create .hugo_build.lock file")
541542
_ = cmd.RegisterFlagCompletionFunc("ignoreVendorPaths", cobra.NoFileCompletions)
542543
cmd.PersistentFlags().String("clock", "", "set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00")
543544
_ = cmd.RegisterFlagCompletionFunc("clock", cobra.NoFileCompletions)
@@ -593,7 +594,6 @@ func applyLocalFlagsBuild(cmd *cobra.Command, r *rootCommand) {
593594
cmd.Flags().BoolVar(&r.forceSyncStatic, "forceSyncStatic", false, "copy all files when static is changed.")
594595
cmd.Flags().BoolP("noTimes", "", false, "don't sync modification time of files")
595596
cmd.Flags().BoolP("noChmod", "", false, "don't sync permission mode of files")
596-
cmd.Flags().BoolP("noBuildLock", "", false, "don't create .hugo_build.lock file")
597597
cmd.Flags().BoolP("printI18nWarnings", "", false, "print missing translations")
598598
cmd.Flags().BoolP("printPathWarnings", "", false, "print warnings on duplicate target paths etc.")
599599
cmd.Flags().BoolP("printUnusedTemplates", "", false, "print warnings on unused templates.")

create/content.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ func NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error
8282
b.setArcheTypeFilenameToUse(ext)
8383

8484
withBuildLock := func() (string, error) {
85-
unlock, err := h.BaseFs.LockBuild()
86-
if err != nil {
87-
return "", fmt.Errorf("failed to acquire a build lock: %s", err)
85+
if !h.Configs.Base.NoBuildLock {
86+
unlock, err := h.BaseFs.LockBuild()
87+
if err != nil {
88+
return "", fmt.Errorf("failed to acquire a build lock: %s", err)
89+
}
90+
defer unlock()
8891
}
89-
defer unlock()
9092

9193
if b.isDir {
9294
return "", b.buildDir()

0 commit comments

Comments
 (0)