-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from cmuench/feature/extension-based-config
New more flexible configuration format [BREAKING CHANGE]
- Loading branch information
Showing
8 changed files
with
259 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,33 @@ | ||
package profile | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
type Profile struct { | ||
fileExtensions []string | ||
} | ||
|
||
func (l *Profile) IsAllowedFileExtension(path string) bool { | ||
|
||
// if profile contains only one extension definition with "*" then allow every extension. | ||
if len(l.fileExtensions) == 1 && l.fileExtensions[0] == "*" { | ||
return true | ||
} | ||
|
||
extension := filepath.Ext(path) | ||
|
||
for _, a := range l.fileExtensions { | ||
if a == extension { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
func (l *Profile) IsAllowedDirectory(path string) bool { | ||
// Exclude some directories by default | ||
excludedDirectories := [...]string{ | ||
"node_modules/", | ||
".idea/", | ||
".git/", | ||
".svn/", | ||
} | ||
|
||
for _, excludedDirectory := range excludedDirectories { | ||
if strings.Contains(path, excludedDirectory) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
Extensions []string | ||
} | ||
|
||
var Default = Profile{ | ||
fileExtensions: []string{"*"}, | ||
Extensions: []string{"*"}, | ||
} | ||
|
||
var LESS = Profile{ | ||
fileExtensions: []string{".less"}, | ||
Extensions: []string{".less"}, | ||
} | ||
|
||
var Magento2Theme = Profile{ | ||
fileExtensions: []string{".css", ".js", ".less", ".sass", ".ts"}, | ||
Extensions: []string{".css", ".js", ".less", ".sass", ".ts"}, | ||
} | ||
|
||
var Magento2 = Profile{ | ||
fileExtensions: []string{".css", ".html", ".less", ".sass", ".js", ".php", ".phtml", ".ts", ".xml"}, | ||
Extensions: []string{".css", ".html", ".less", ".sass", ".js", ".php", ".phtml", ".ts", ".xml"}, | ||
} | ||
|
||
var SASS = Profile{ | ||
fileExtensions: []string{".sass", ".scss"}, | ||
Extensions: []string{".sass", ".scss"}, | ||
} | ||
|
||
var VueStorefront = Profile{ | ||
fileExtensions: []string{".css", ".js", ".sass", ".ts"}, | ||
Extensions: []string{".css", ".js", ".sass", ".ts"}, | ||
} | ||
|
||
var Javascript = Profile{ | ||
fileExtensions: []string{".js", ".ts"}, | ||
Extensions: []string{".js", ".ts"}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.