Skip to content

Commit

Permalink
support .PL .pm file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hideo Hattori committed Apr 6, 2016
1 parent 454ed0a commit 9d8b341
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion language.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Language struct {
type Languages []Language

var reShebangEnv *regexp.Regexp = regexp.MustCompile("^#! *(\\S+/env) ([a-zA-Z]+)")
var reShebangLang *regexp.Regexp = regexp.MustCompile("^#! */[a-zA-Z/]+/([a-zA-Z]+)")
var reShebangLang *regexp.Regexp = regexp.MustCompile("^#! *[.a-zA-Z/]+/([a-zA-Z]+)")

func (ls Languages) Len() int {
return len(ls)
Expand Down Expand Up @@ -105,7 +105,9 @@ var Exts map[string]string = map[string]string{
"mustache": "mustache",
"php": "php",
"pas": "pas",
"PL": "pl",
"pl": "pl",
"pm": "pl",
"plan9sh": "plan9sh",
"text": "text",
"txt": "text",
Expand Down
14 changes: 14 additions & 0 deletions language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,17 @@ func TestGetShebangPlan9Shell(t *testing.T) {
t.Errorf("invalid logic. lang=[%v] shebang=[%v]", lang, s)
}
}

func TestGetShebangStartDot(t *testing.T) {
lang := "pl"
shebang := "#!./perl -o"

s, ok := getShebang(shebang)
if !ok {
t.Errorf("invalid logic. shebang=[%v]", shebang)
}

if lang != s {
t.Errorf("invalid logic. lang=[%v] shebang=[%v]", lang, s)
}
}

0 comments on commit 9d8b341

Please sign in to comment.