aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorguangwu <[email protected]>2024-04-08 21:23:08 +0800
committerGitHub <[email protected]>2024-04-08 15:23:08 +0200
commit7907935a423b2a788afc7c68f6b6419efa70cc7b (patch)
treec542dcfebbccd184d9e6831755be3703a52eabe1
parent02d5ec14f3fea20fa05aa2f0c2b9698620633edc (diff)
downloadhugo-7907935a423b2a788afc7c68f6b6419efa70cc7b.tar.gz
hugo-7907935a423b2a788afc7c68f6b6419efa70cc7b.zip
babel: Close file before removing
-rw-r--r--resources/resource_transformers/babel/babel.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/resources/resource_transformers/babel/babel.go b/resources/resource_transformers/babel/babel.go
index 212331d8e..6a03f7b3b 100644
--- a/resources/resource_transformers/babel/babel.go
+++ b/resources/resource_transformers/babel/babel.go
@@ -172,7 +172,10 @@ func (t *babelTransformation) Transform(ctx *resources.ResourceTransformationCtx
cmdArgs = append(cmdArgs, hexec.WithStdout(stderr))
cmdArgs = append(cmdArgs, hexec.WithEnviron(hugo.GetExecEnviron(t.rs.Cfg.BaseConfig().WorkingDir, t.rs.Cfg, t.rs.BaseFs.Assets.Fs)))
- defer os.Remove(compileOutput.Name())
+ defer func() {
+ compileOutput.Close()
+ os.Remove(compileOutput.Name())
+ }()
// ARGA [--no-install babel --config-file /private/var/folders/_g/j3j21hts4fn7__h04w2x8gb40000gn/T/hugo-test-babel812882892/babel.config.js --source-maps --filename=js/main2.js --out-file=/var/folders/_g/j3j21hts4fn7__h04w2x8gb40000gn/T/compileOut-2237820197.js]
// [--no-install babel --config-file /private/var/folders/_g/j3j21hts4fn7__h04w2x8gb40000gn/T/hugo-test-babel332846848/babel.config.js --filename=js/main.js --out-file=/var/folders/_g/j3j21hts4fn7__h04w2x8gb40000gn/T/compileOut-1451390834.js 0x10304ee60 0x10304ed60 0x10304f060]