@@ -54,7 +54,7 @@ func New(path *paths.Path) (*Sketch, error) {
5454 } else if ! exist {
5555 return nil , fmt .Errorf ("%s: %s" , tr ("no such file or directory" ), path )
5656 }
57- if _ , validIno := globals .MainFileValidExtensions [path .Ext ()]; validIno && ! path .IsDir () {
57+ if globals .MainFileValidExtensions [path .Ext ()] && ! path .IsDir () {
5858 path = path .Parent ()
5959 }
6060
@@ -121,7 +121,7 @@ func New(path *paths.Path) (*Sketch, error) {
121121 f .Close ()
122122
123123 ext := p .Ext ()
124- if _ , found := globals .MainFileValidExtensions [ext ]; found {
124+ if globals .MainFileValidExtensions [ext ] {
125125 if p .EqualsTo (mainFile ) {
126126 // The main file must not be included in the lists of other files
127127 continue
@@ -132,7 +132,7 @@ func New(path *paths.Path) (*Sketch, error) {
132132 sketch .OtherSketchFiles .Add (p )
133133 sketch .RootFolderFiles .Add (p )
134134 }
135- } else if _ , found := globals .AdditionalFileValidExtensions [ext ]; found {
135+ } else if globals .AdditionalFileValidExtensions [ext ] {
136136 // If the user exported the compiles binaries to the Sketch "build" folder
137137 // they would be picked up but we don't want them, so we skip them like so
138138 if p .IsInsideDir (sketch .FullPath .Join ("build" )) {
@@ -158,12 +158,8 @@ func New(path *paths.Path) (*Sketch, error) {
158158// supportedFiles reads all files recursively contained in Sketch and
159159// filter out unneded or unsupported ones and returns them
160160func (s * Sketch ) supportedFiles () (* paths.PathList , error ) {
161- validExtensions := []string {}
162- for ext := range globals .MainFileValidExtensions {
163- validExtensions = append (validExtensions , ext )
164- }
165- for ext := range globals .AdditionalFileValidExtensions {
166- validExtensions = append (validExtensions , ext )
161+ filterValidExtensions := func (p * paths.Path ) bool {
162+ return globals .MainFileValidExtensions [p .Ext ()] || globals .AdditionalFileValidExtensions [p .Ext ()]
167163 }
168164
169165 filterOutBuildPaths := func (p * paths.Path ) bool {
@@ -174,7 +170,7 @@ func (s *Sketch) supportedFiles() (*paths.PathList, error) {
174170 filterOutBuildPaths ,
175171 paths .AndFilter (
176172 paths .FilterOutPrefixes ("." ),
177- paths . FilterSuffixes ( validExtensions ... ) ,
173+ filterValidExtensions ,
178174 paths .FilterOutDirectories (),
179175 ),
180176 )
0 commit comments