Debian Codegraph @

common/hexec/exec_integration_test.go

raw ◀ ▶
1 Debian patch touch this file
1 // Copyright 2026 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 hexec_test
15
16 import (
17 "testing"
18
19 "github.com/gohugoio/hugo/htesting"
20 "github.com/gohugoio/hugo/hugolib"
21 )
22
23 func TestNPMGlobalInstalls(t *testing.T) {
•24 t.Skip("This tests needs internet access")
25 if !htesting.IsRealCI() {
26 t.Skip("We only ever want to run this in CI.")
27 }
28 files := `
29 -- hugo.toml --
30 disableKinds = ["taxonomy", "term"]
31 [security.exec]
32 allow = ['^(babel|node|postcss|tailwindcss)$']
33
34 -- package.json --
35 {}
36 -- hugo_stats.json --
37 -- assets/js/main.js --
38 console.log("Hello, world!");
39 -- assets/css/main1.css --
40 body { color: red }
41 -- assets/css/main2.css --
42 @import "tailwindcss";
43 @plugin "@tailwindcss/typography";
44 @source "hugo_stats.json";
45 body { color: blue }
46 -- layouts/home.html --
47 {{ with resources.Get "css/main1.css" }}
48 {{ with . | css.PostCSS }}
49 CSS1: {{ .RelPermalink }}|{{ gt (.Content | len) 10 }}|
50 {{ end }}
51 {{ end }}
52 {{ with resources.Get "css/main2.css" }}
53 {{ with . | css.TailwindCSS }}
54 CSS2: {{ .RelPermalink }}|{{ gt (.Content | len) 10 }}|
55 {{ end }}
56 {{ end }}
57 {{ with resources.Get "js/main.js" }}
58 {{ with . | js.Babel }}
59 JS: {{ .RelPermalink }}|{{ gt (.Content | len) 10 }}|
60 {{ end }}
61 {{ end }}
62 `
63
64 b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstallGlobal(
65 "postcss", "postcss-cli",
66 "@babel/core", "@babel/cli",
67 "tailwindcss", "@tailwindcss/cli", "@tailwindcss/typography",
68 ))
69
70 b.AssertFileContent("public/index.html",
71 "CSS1: /css/main1.css|true|",
72 "CSS2: /css/main2.css|true|",
73 "JS: /js/main.js|true|",
74 )
75 }