Skip to content

Commit 92e2a99

Browse files
author
Minggang Wang
committed
Run rclnodejs with Node.js (>= 10 and <=12) on appveyor
Recently, we observerd that rcnodejs is not supported by some version of Node.js, because some new features the current JS code used are not supported by these versions yet. This patch replaces these cases with compatible patterns. As the nodejs v8.x has been EOF already (https://nodejs.org/en/about/releases/), we decided to drop it. (Another reason is that some depenency of rclnodejs requires nodejs >= 10.x) Meanwhile, we are going to use a matrix to run Node.js (LTS) version for both 10 and 12. Fix #768
1 parent b029dbc commit 92e2a99

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ rclnodejs.init().then(() => {
3838

3939
Before installing `rclnodejs` please ensure the following softare is installed and configured on your systemd:
4040

41-
- [Nodejs](https://nodejs.org/en/) version between 8.12 - 12.x.
41+
- [Nodejs](https://nodejs.org/en/) version between 10.23.1 - 12.x.
4242

4343
- [ROS 2 SDK](https://index.ros.org/doc/ros2/Installation/) for details.
4444
**DON'T FORGET TO [SOURCE THE ROS 2 SETUP FILE](https://index.ros.org/doc/ros2/Tutorials/Configuring-ROS2-Environment/#source-the-setup-files)**

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ branches:
77
image: Visual Studio 2019
88

99
environment:
10-
nodejs_version: "12"
1110
PYTHON3: "c:\\Python37-x64"
1211
PYTHON2: "c:\\Python27"
12+
matrix:
13+
- nodejs_version: "10"
14+
- nodejs_version: "12"
1315

1416
clone_folder: c:\proj\rclnodejs
1517

lib/context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ let defaultContext = null;
4444
* to the usable 'initialized' (valid) state be using.
4545
*/
4646
class Context {
47-
static _instances = [];
48-
4947
/**
5048
* Access the list of usable (initialized/valid) contexts.
5149
* @returns {Context[]} Array of valid contexts
@@ -223,4 +221,6 @@ class Context {
223221
}
224222
}
225223

224+
Context._instances = [];
225+
226226
module.exports = Context;

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"compare-versions": "^3.6.0",
6161
"debug": "^4.1.1",
6262
"dot": "^1.1.3",
63-
"fs-extra": "^9.0.1",
63+
"fs-extra": "^9.1.0",
6464
"is-close": "^1.3.3",
6565
"mkdirp": "^1.0.4",
6666
"mz": "^2.7.0",
@@ -70,7 +70,8 @@
7070
"ref-struct-di": "^1.1.1",
7171
"walk": "^2.3.14",
7272
"uuid": "^8.2.0",
73-
"int64-napi": "^1.0.1"
73+
"int64-napi": "^1.0.1",
74+
"array.prototype.flat": "^1.2.4"
7475
},
7576
"husky": {
7677
"hooks": {
@@ -86,6 +87,6 @@
8687
]
8788
},
8889
"engines": {
89-
"node": ">= 8.12.0 <13.0.0"
90+
"node": ">= 10.23.1 <13.0.0"
9091
}
9192
}

rosidl_gen/packages.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const readline = require('readline');
2020
const path = require('path');
2121
const walk = require('walk');
2222
const os = require('os');
23+
const flat = require('array.prototype.flat');
2324

2425
const fsp = fs.promises;
2526

@@ -135,9 +136,13 @@ async function getPackageDefinitionsFiles(packageName, amentRoot) {
135136
*/
136137
async function findAmentPackagesInDirectory(dir) {
137138
const pkgs = await getAmentPackages(dir);
138-
const rosFiles = (
139-
await Promise.all(pkgs.map((pkg) => getPackageDefinitionsFiles(pkg, dir)))
140-
).flat();
139+
const files = await Promise.all(
140+
pkgs.map((pkg) => getPackageDefinitionsFiles(pkg, dir))
141+
);
142+
143+
// Support flat() methond for nodejs < 11.
144+
const rosFiles = Array.prototype.flat ? files.flat() : flat(files);
145+
141146
const pkgMap = new Map();
142147
return new Promise((resolve, reject) => {
143148
rosFiles.forEach((filePath) => {

test/blocklist.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"Linux": ["test-multi-nodes.js", "test-msg-type-py-node.js", "test-msg-type-cpp-node.js", "test-cross-lang.js"],
33
"Darwin": ["test-multi-nodes.js", "test-msg-type-py-node.js", "test-msg-type-cpp-node.js", "test-cross-lang.js"],
4-
"Windows_NT": ["test-multi-nodes.js", "test-msg-type-py-node.js", "test-msg-type-cpp-node.js", "test-cross-lang.js"]
4+
"Windows_NT": ["test-multi-nodes.js", "test-msg-type-py-node.js", "test-msg-type-cpp-node.js", "test-cross-lang.js", "test-generate-messages-bin.js"]
55
}

0 commit comments

Comments
 (0)