Skip to content

Commit 7e4c65c

Browse files
authored
Support jest-environment directive (#46)
* Support jest-environment directive * Fix test case
1 parent 4af9285 commit 7e4c65c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

addlicense/main.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ func walk(ch chan<- *file, start string, logger *log.Logger) error {
295295
// Patterns are assumed to be valid.
296296
func fileMatches(path string, patterns []string) bool {
297297
for _, p := range patterns {
298-
298+
299299
if runtime.GOOS == "windows" {
300300
// If on windows, change path seperators to /
301-
// in order for patterns to compare correctly
301+
// in order for patterns to compare correctly
302302
path = filepath.ToSlash(path)
303303
}
304-
304+
305305
// ignore error, since we assume patterns are valid
306306
if match, _ := doublestar.Match(p, path); match {
307307
return true
@@ -412,6 +412,7 @@ var head = []string{
412412
"<?php", // PHP opening tag
413413
"# escape", // Dockerfile directive https://docs.docker.com/engine/reference/builder/#parser-directives
414414
"# syntax", // Dockerfile directive https://docs.docker.com/engine/reference/builder/#parser-directives
415+
"/** @jest-environment", // Jest Environment string https://jestjs.io/docs/configuration#testenvironment-string
415416
}
416417

417418
func hashBang(b []byte) []byte {

addlicense/main_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func TestAddLicense(t *testing.T) {
245245
{"<?php\ncontent", "<?php\n// HYS\n\ncontent", true},
246246
{"# escape: `\ncontent", "# escape: `\n// HYS\n\ncontent", true},
247247
{"# syntax: docker/dockerfile:1.3\ncontent", "# syntax: docker/dockerfile:1.3\n// HYS\n\ncontent", true},
248+
{"/** @jest-environment jsdom */\ncontent", "/** @jest-environment jsdom */\n// HYS\n\ncontent", true},
248249

249250
// ensure files with existing license or generated files are
250251
// skipped. No need to test all permutations of these, since

0 commit comments

Comments
 (0)