@@ -21,6 +21,7 @@ const path = require('path');
21
21
const walk = require ( 'walk' ) ;
22
22
const os = require ( 'os' ) ;
23
23
const flat = require ( 'array.prototype.flat' ) ;
24
+ const pkgFilters = require ( '../rosidl_gen/filter.js' ) ;
24
25
25
26
const fsp = fs . promises ;
26
27
@@ -140,28 +141,28 @@ async function findAmentPackagesInDirectory(dir) {
140
141
pkgs . map ( ( pkg ) => getPackageDefinitionsFiles ( pkg , dir ) )
141
142
) ;
142
143
143
- // Support flat() methond for nodejs < 11.
144
+ // Support flat() method for nodejs < 11.
144
145
const rosFiles = Array . prototype . flat ? files . flat ( ) : flat ( files ) ;
145
146
146
147
const pkgMap = new Map ( ) ;
147
148
return new Promise ( ( resolve , reject ) => {
148
149
rosFiles . forEach ( ( filePath ) => {
149
- if ( path . extname ( filePath ) === '.msg' ) {
150
- // Some .msg files were generated prior to 0.3.2 for .action files,
151
- // which has been disabled. So these files should be ignored here.
152
- if ( path . dirname ( dir ) . split ( path . sep ) . pop ( ) !== 'action' ) {
153
- addInterfaceInfo (
154
- grabInterfaceInfo ( filePath , true ) ,
155
- 'messages' ,
156
- pkgMap
157
- ) ;
150
+ const interfaceInfo = grabInterfaceInfo ( filePath , true ) ;
151
+ const ignore = pkgFilters . matchesAny ( interfaceInfo ) ;
152
+ if ( ! ignore ) {
153
+ if ( path . extname ( filePath ) === '.msg' ) {
154
+ // Some .msg files were generated prior to 0.3.2 for .action files,
155
+ // which has been disabled. So these files should be ignored here.
156
+ if ( path . dirname ( dir ) . split ( path . sep ) . pop ( ) !== 'action' ) {
157
+ addInterfaceInfo ( interfaceInfo , 'messages' , pkgMap ) ;
158
+ }
159
+ } else if ( path . extname ( filePath ) === '.srv' ) {
160
+ addInterfaceInfo ( interfaceInfo , 'services' , pkgMap ) ;
161
+ } else if ( path . extname ( filePath ) === '.action' ) {
162
+ addInterfaceInfo ( interfaceInfo , 'actions' , pkgMap ) ;
163
+ } else {
164
+ // we ignore all other files
158
165
}
159
- } else if ( path . extname ( filePath ) === '.srv' ) {
160
- addInterfaceInfo ( grabInterfaceInfo ( filePath , true ) , 'services' , pkgMap ) ;
161
- } else if ( path . extname ( filePath ) === '.action' ) {
162
- addInterfaceInfo ( grabInterfaceInfo ( filePath , true ) , 'actions' , pkgMap ) ;
163
- } else {
164
- // we ignore all other files
165
166
}
166
167
} ) ;
167
168
resolve ( pkgMap ) ;
@@ -191,30 +192,25 @@ async function findPackagesInDirectory(dir) {
191
192
let walker = walk . walk ( dir , { followLinks : true } ) ;
192
193
let pkgMap = new Map ( ) ;
193
194
walker . on ( 'file' , ( root , file , next ) => {
194
- if ( path . extname ( file . name ) === '.msg' ) {
195
- // Some .msg files were generated prior to 0.3.2 for .action files,
196
- // which has been disabled. So these files should be ignored here.
197
- if ( path . dirname ( root ) . split ( path . sep ) . pop ( ) !== 'action' ) {
198
- addInterfaceInfo (
199
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
200
- 'messages' ,
201
- pkgMap
202
- ) ;
195
+ const interfaceInfo = grabInterfaceInfo (
196
+ path . join ( root , file . name ) ,
197
+ amentExecuted
198
+ ) ;
199
+ const ignore = pkgFilters . matchesAny ( interfaceInfo ) ;
200
+ if ( ! ignore ) {
201
+ if ( path . extname ( file . name ) === '.msg' ) {
202
+ // Some .msg files were generated prior to 0.3.2 for .action files,
203
+ // which has been disabled. So these files should be ignored here.
204
+ if ( path . dirname ( root ) . split ( path . sep ) . pop ( ) !== 'action' ) {
205
+ addInterfaceInfo ( interfaceInfo , 'messages' , pkgMap ) ;
206
+ }
207
+ } else if ( path . extname ( file . name ) === '.srv' ) {
208
+ addInterfaceInfo ( interfaceInfo , 'services' , pkgMap ) ;
209
+ } else if ( path . extname ( file . name ) === '.action' ) {
210
+ addInterfaceInfo ( interfaceInfo , 'actions' , pkgMap ) ;
211
+ } else {
212
+ // we ignore all other files
203
213
}
204
- } else if ( path . extname ( file . name ) === '.srv' ) {
205
- addInterfaceInfo (
206
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
207
- 'services' ,
208
- pkgMap
209
- ) ;
210
- } else if ( path . extname ( file . name ) === '.action' ) {
211
- addInterfaceInfo (
212
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
213
- 'actions' ,
214
- pkgMap
215
- ) ;
216
- } else {
217
- // we ignore all other files
218
214
}
219
215
next ( ) ;
220
216
} ) ;
0 commit comments