File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -467,7 +467,8 @@ func scanGoDirs(goRoot bool) {
467
467
}
468
468
if typ == os .ModeDir {
469
469
base := filepath .Base (path )
470
- if base == "" || base [0 ] == '.' || base [0 ] == '_' || base == "testdata" {
470
+ if base == "" || base [0 ] == '.' || base [0 ] == '_' ||
471
+ base == "testdata" || base == "node_modules" {
471
472
return filepath .SkipDir
472
473
}
473
474
fi , err := os .Lstat (path )
Original file line number Diff line number Diff line change @@ -1346,6 +1346,26 @@ func TestIgnoreConfiguration(t *testing.T) {
1346
1346
})
1347
1347
}
1348
1348
1349
+ // Skip "node_modules" directory.
1350
+ func TestSkipNodeModules (t * testing.T ) {
1351
+ testConfig {
1352
+ gopathFiles : map [string ]string {
1353
+ "example.net/node_modules/pkg/a.go" : "package pkg\n const X = 1" ,
1354
+ "otherwise-longer.net/not_modules/pkg/a.go" : "package pkg\n const X = 1" ,
1355
+ },
1356
+ }.test (t , func (t * goimportTest ) {
1357
+ const in = "package x\n \n const _ = pkg.X\n "
1358
+ const want = "package x\n \n import \" otherwise-longer.net/not_modules/pkg\" \n \n const _ = pkg.X\n "
1359
+ buf , err := Process (t .gopath + "/src/x/x.go" , []byte (in ), nil )
1360
+ if err != nil {
1361
+ t .Fatal (err )
1362
+ }
1363
+ if string (buf ) != want {
1364
+ t .Errorf ("wrong output.\n got:\n %q\n want:\n %q\n " , buf , want )
1365
+ }
1366
+ })
1367
+ }
1368
+
1349
1369
func strSet (ss []string ) map [string ]bool {
1350
1370
m := make (map [string ]bool )
1351
1371
for _ , s := range ss {
You can’t perform that action at this time.
0 commit comments