forked from RobotWebTools/rclnodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RosPackageFilters & blocklist.json
On windows workflow use node 18.12.0 inplace of 18.13.0. There is a repeatable issue with node-gyp configuration on node 18.13. It seems to be related to the node cache. Switching to 18.12 avoids using a cached version of node 18 and the issue no longer occurs. Fix RobotWebTools#890
- Loading branch information
1 parent
d5acae6
commit d7f4f8c
Showing
7 changed files
with
158 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
{ | ||
"pkgName": "rosbag2_storage_mcap_testdata" | ||
} | ||
] |
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
// blocklist.json format | ||
// [ | ||
// { | ||
// pkgName: RegExString, | ||
// interfaceName: RegExString, | ||
// os: RegExString | ||
// }, | ||
// ... | ||
// ] | ||
// | ||
// examples | ||
// [ | ||
// { | ||
// "pkgName": "action*" | ||
// }, | ||
// { | ||
// "pkgName": "std_msgs", | ||
// }, | ||
// { | ||
// "pkgName": "std_msgs", | ||
// "interfaceName": "String" | ||
// }, | ||
// { | ||
// "os": "Linux" | ||
// }, | ||
// ] | ||
|
||
const RosPackageFilters = { | ||
filters: [], | ||
_loaded: false, | ||
|
||
addFilter: function (pkgName, interfaceName, os) { | ||
this.filters.push({ | ||
pkgName: pkgName, | ||
interfaceName: interfaceName, | ||
os: os, | ||
}); | ||
}, | ||
|
||
_matches: function (filter, pkgInfo) { | ||
if (filter.os && filter.os.test(os.type())) { | ||
return true; | ||
} | ||
|
||
if (filter.pkgName) { | ||
if (filter.pkgName.test(pkgInfo.pkgName)) { | ||
if (!filter.interfaceName) { | ||
return true; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
if ( | ||
filter.interfaceName && | ||
filter.interfaceName.test(pkgInfo.interfaceName) | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
load: function ( | ||
blocklistPath = path.join(__dirname, '../rosidl_gen/blocklist.json') | ||
) { | ||
this._loaded = true; | ||
|
||
if (!fs.existsSync(blocklistPath)) return; | ||
|
||
// eslint-disable-next-line | ||
let blocklistData = JSON.parse(fs.readFileSync(blocklistPath, 'utf8')); | ||
|
||
let filters = blocklistData.map((pkgFilterData) => { | ||
let filter = {}; | ||
if (pkgFilterData['pkgName']) { | ||
filter.pkgName = new RegExp(pkgFilterData.pkgName); | ||
} | ||
if (pkgFilterData['interfaceName']) { | ||
filter.interfaceName = new RegExp(pkgFilterData.interfaceName); | ||
} | ||
if (pkgFilterData['os']) { | ||
filter.os = new RegExp(pkgFilterData.os); | ||
} | ||
return filter; | ||
}); | ||
|
||
this.filters = filters.filter( | ||
(filter) => !filter.os || filter.os.test(os.type()) | ||
); | ||
}, | ||
|
||
matchesAny: function (pkgInfo) { | ||
if (!this._loaded) this.load(); | ||
return this.filters.some((filter) => this._matches(filter, pkgInfo)); | ||
}, | ||
}; | ||
|
||
module.exports = RosPackageFilters; |
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