"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hugolib/js_test.go" between
hugo-0.80.0.tar.gz and hugo-0.81.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

js_test.go  (hugo-0.80.0):js_test.go  (hugo-0.81.0)
skipping to change at line 41 skipping to change at line 41
"github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/common/loggers"
) )
func TestJSBuildWithNPM(t *testing.T) { func TestJSBuildWithNPM(t *testing.T) {
if !htesting.IsCI() { if !htesting.IsCI() {
t.Skip("skip (relative) long running modules test when running lo cally") t.Skip("skip (relative) long running modules test when running lo cally")
} }
if runtime.GOOS == "windows" {
t.Skip("skip NPM test on Windows")
}
wd, _ := os.Getwd() wd, _ := os.Getwd()
defer func() { defer func() {
os.Chdir(wd) os.Chdir(wd)
}() }()
c := qt.New(t) c := qt.New(t)
mainJS := ` mainJS := `
import "./included"; import "./included";
import { toCamelCase } from "to-camel-case"; import { toCamelCase } from "to-camel-case";
skipping to change at line 112 skipping to change at line 108
b.WithWorkingDir(workDir) b.WithWorkingDir(workDir)
b.WithViper(v) b.WithViper(v)
b.WithContent("p1.md", "") b.WithContent("p1.md", "")
b.WithTemplates("index.html", ` b.WithTemplates("index.html", `
{{ $options := dict "minify" false "externals" (slice "react" "react-dom") }} {{ $options := dict "minify" false "externals" (slice "react" "react-dom") }}
{{ $js := resources.Get "js/main.js" | js.Build $options }} {{ $js := resources.Get "js/main.js" | js.Build $options }}
JS: {{ template "print" $js }} JS: {{ template "print" $js }}
{{ $jsx := resources.Get "js/myjsx.jsx" | js.Build $options }} {{ $jsx := resources.Get "js/myjsx.jsx" | js.Build $options }}
JSX: {{ template "print" $jsx }} JSX: {{ template "print" $jsx }}
{{ $ts := resources.Get "js/myts.ts" | js.Build }} {{ $ts := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "inline")}}
TS: {{ template "print" $ts }} TS: {{ template "print" $ts }}
{{ $ts2 := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "external" "T
argetPath" "js/myts2.js")}}
TS2: {{ template "print" $ts2 }}
{{ define "print" }}RelPermalink: {{.RelPermalink}}|MIME: {{ .MediaType }}|Conte nt: {{ .Content | safeJS }}{{ end }} {{ define "print" }}RelPermalink: {{.RelPermalink}}|MIME: {{ .MediaType }}|Conte nt: {{ .Content | safeJS }}{{ end }}
`) `)
jsDir := filepath.Join(workDir, "assets", "js") jsDir := filepath.Join(workDir, "assets", "js")
fmt.Println(workDir)
b.Assert(os.MkdirAll(jsDir, 0777), qt.IsNil) b.Assert(os.MkdirAll(jsDir, 0777), qt.IsNil)
b.Assert(os.Chdir(workDir), qt.IsNil) b.Assert(os.Chdir(workDir), qt.IsNil)
b.WithSourceFile("package.json", packageJSON) b.WithSourceFile("package.json", packageJSON)
b.WithSourceFile("assets/js/main.js", mainJS) b.WithSourceFile("assets/js/main.js", mainJS)
b.WithSourceFile("assets/js/myjsx.jsx", jsxContent) b.WithSourceFile("assets/js/myjsx.jsx", jsxContent)
b.WithSourceFile("assets/js/myts.ts", tsContent) b.WithSourceFile("assets/js/myts.ts", tsContent)
b.WithSourceFile("assets/js/included.js", includedJS) b.WithSourceFile("assets/js/included.js", includedJS)
cmd, err := hexec.SafeCommand("npm", "install") cmd, err := hexec.SafeCommand("npm", "install")
b.Assert(err, qt.IsNil) b.Assert(err, qt.IsNil)
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
b.Assert(err, qt.IsNil, qt.Commentf(string(out))) b.Assert(err, qt.IsNil, qt.Commentf(string(out)))
b.Build(BuildCfg{}) b.Build(BuildCfg{})
b.AssertFileContent("public/js/myts.js", `//# sourceMappingURL=data:appli
cation/json;base64,ewogICJ2ZXJz`)
b.AssertFileContent("public/js/myts2.js.map", `"version": 3,`)
b.AssertFileContent("public/index.html", ` b.AssertFileContent("public/index.html", `
console.log("included"); console.log("included");
if (hasSpace.test(string)) if (hasSpace.test(string))
var React = __toModule(require("react")); var React = __toModule(require("react"));
function greeter(person) { function greeter(person) {
`) `)
} }
func TestJSBuild(t *testing.T) { func TestJSBuild(t *testing.T) {
if !htesting.IsCI() { if !htesting.IsCI() {
skipping to change at line 184 skipping to change at line 184
`, workDir) `, workDir)
b := newTestSitesBuilder(t) b := newTestSitesBuilder(t)
b.Fs = hugofs.NewDefault(viper.New()) b.Fs = hugofs.NewDefault(viper.New())
b.WithWorkingDir(workDir).WithConfigFile("toml", config).WithLogger(logge rs.NewInfoLogger()) b.WithWorkingDir(workDir).WithConfigFile("toml", config).WithLogger(logge rs.NewInfoLogger())
b.WithSourceFile("go.mod", `module github.com/gohugoio/tests/testHugoModu les b.WithSourceFile("go.mod", `module github.com/gohugoio/tests/testHugoModu les
go 1.15 go 1.15
require github.com/gohugoio/hugoTestProjectJSModImports v0.5.0 // indirect require github.com/gohugoio/hugoTestProjectJSModImports v0.9.0 // indirect
`) `)
b.WithContent("p1.md", "").WithNothingAdded() b.WithContent("p1.md", "").WithNothingAdded()
b.WithSourceFile("package.json", `{ b.WithSourceFile("package.json", `{
"dependencies": { "dependencies": {
"date-fns": "^2.16.1" "date-fns": "^2.16.1"
} }
}`) }`)
skipping to change at line 211 skipping to change at line 211
b.Build(BuildCfg{}) b.Build(BuildCfg{})
b.AssertFileContent("public/js/main.js", ` b.AssertFileContent("public/js/main.js", `
greeting: "greeting configured in mod2" greeting: "greeting configured in mod2"
Hello1 from mod1: $ Hello1 from mod1: $
return "Hello2 from mod1"; return "Hello2 from mod1";
var Hugo = "Rocks!"; var Hugo = "Rocks!";
Hello3 from mod2. Date from date-fns: ${today} Hello3 from mod2. Date from date-fns: ${today}
Hello from lib in the main project Hello from lib in the main project
Hello5 from mod2. Hello5 from mod2.
var myparam = "Hugo Rocks!";`) var myparam = "Hugo Rocks!";
shim cwd
`)
// React JSX, verify the shimming.
b.AssertFileContent("public/js/like.js", `@v0.9.0/assets/js/shims/react.j
s
module.exports = window.ReactDOM;
`)
} }
 End of changes. 7 change blocks. 
8 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)