Skip to content

Commit cd9a660

Browse files
author
Comick
committed
use node builtin promises and node >=14 supported
1 parent 88a4e85 commit cd9a660

6 files changed

Lines changed: 20 additions & 48 deletions

File tree

.github/workflows/test.js.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [12.x, 14.x, 16.x, 18.x, 19.x]
19+
# Kept current with https://github.com/nodejs/release#release-schedule
20+
node-version: [14.x, 16.x, 18.x, 19.x]
2021
robot-version: [3.2.2, 4.1.3, 5.0, 6.0.1]
2122
steps:
2223
- uses: actions/checkout@v3

bin/botclient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ var robot = require('../lib/robotremote'),
88
var options = {host: process.argv[2] || 'localhost', port: parseInt(process.argv[3], 10) || 8270};
99
var serverString = options.host + ':' + options.port;
1010

11-
robot.createClient(options).then(function (keywords) {
11+
robot.createClient(options).then(keywords -> {
1212
console.log('Connected to remote server at "' + serverString + '"');
1313
console.log('Available keywords: ' + Object.keys(keywords).join(', '));
1414
repl.start(serverString + '> ').context.keywords = keywords;
15-
}, function (err) {
15+
}, err -> {
1616
console.log('Could not connected to remote server at "' + serverString + '"');
1717
throw err;
1818
});

lib/robotremote.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Server.prototype.runKeyword = function (name, params, response) {
163163
keywordReturn(e);
164164
return;
165165
}
166-
if (isPromise(result)) {
166+
if (util.types.isPromise(result)) {
167167
result.then(keywordReturn, keywordReturn);
168168
} else {
169169
// Got sync keyword return.
@@ -199,7 +199,6 @@ function KeywordLogger(writeOutput) {
199199
* @constructor
200200
*/
201201
function createClient(options) {
202-
var Promise = require('promise');
203202
var result = new Promise(function (resolve, reject) {
204203
//options.path = '/';
205204
var client = xmlrpc.createClient(options);
@@ -239,30 +238,4 @@ function createClient(options) {
239238
return result;
240239
}
241240

242-
/**
243-
* isPromise is Copyright (c) 2014 Forbes Lindesay
244-
*
245-
* Permission is hereby granted, free of charge, to any person obtaining a copy
246-
* of this software and associated documentation files (the "Software"), to deal
247-
* in the Software without restriction, including without limitation the rights
248-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
249-
* copies of the Software, and to permit persons to whom the Software is
250-
* furnished to do so, subject to the following conditions:
251-
*
252-
* The above copyright notice and this permission notice shall be included in
253-
* all copies or substantial portions of the Software.
254-
*
255-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
256-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
257-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
258-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
259-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
260-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
261-
* THE SOFTWARE.
262-
*
263-
*/
264-
function isPromise(obj) {
265-
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
266-
}
267-
268241
module.exports.createClient = createClient;

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test",
1212
"ATDD"
1313
],
14-
"version": "1.4.1",
14+
"version": "1.5.0",
1515
"preferGlobal": false,
1616
"homepage": "https://github.com/comick/node-robotremoteserver",
1717
"author": {
@@ -33,8 +33,7 @@
3333
},
3434
"main": "./lib/robotremote.js",
3535
"dependencies": {
36-
"xmlrpc": ">=1.3.2",
37-
"promise": ">=8.1.0"
36+
"xmlrpc": ">=1.3.2"
3837
},
3938
"devDependencies": {
4039
"mocha": ">=8.0.1"
@@ -43,7 +42,7 @@
4342
"test": "mocha && (pybot test || robot test)"
4443
},
4544
"engines": {
46-
"node": ">=0.10",
45+
"node": ">=14.0",
4746
"npm": ">=1.4.0"
4847
},
4948
"licenses": [

test/test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Robot Remote Library', function () {
2626
it('client should fail to start if server is not running', function (done) {
2727
// In case of slow DNS this will fail after 2000ms
2828
this.timeout(5000);
29-
robot.createClient({host: 'localhost', port: nextPort()}).done(
29+
robot.createClient({host: 'localhost', port: nextPort()}).then(
3030
function (val) {
3131
throw new Error('client succeeded');
3232
},
@@ -38,7 +38,7 @@ describe('Robot Remote Library', function () {
3838
it('client should start and list all keywords when server is running', function (done) {
3939
var serverPort = nextPort();
4040
server = new robot.Server([testLibrary], {host: 'localhost', port: serverPort, allowStop: true}, function () {
41-
robot.createClient({host: 'localhost', port: serverPort}).done(
41+
robot.createClient({host: 'localhost', port: serverPort}).then(
4242
function (val) {
4343
keywordsEqual(val, server.keywords);
4444
done();
@@ -65,9 +65,9 @@ describe('Robot Remote Library', function () {
6565
{testKeyword: testKeyword}
6666
];
6767
server = new robot.Server(libraries, {host: 'localhost', port: serverPort, allowStop: true}, function () {
68-
robot.createClient({host: 'localhost', port: serverPort}).done(
68+
robot.createClient({host: 'localhost', port: serverPort}).then(
6969
function (clientKeywords) {
70-
clientKeywords.testKeyword('param').done(function (val) {
70+
clientKeywords.testKeyword('param').then(function (val) {
7171
});
7272
}, done
7373
);
@@ -87,9 +87,9 @@ describe('Robot Remote Library', function () {
8787
}
8888
};
8989
server = new robot.Server([lib], {host: 'localhost', port: serverPort, allowStop: true}, function () {
90-
robot.createClient({host: 'localhost', port: serverPort}).done(
90+
robot.createClient({host: 'localhost', port: serverPort}).then(
9191
function (val) {
92-
val.testKeyword('param').done(function (res) {
92+
val.testKeyword('param').then(function (res) {
9393
assert.deepEqual(res, {
9494
output: util.format('*WARN:%d* message\n*TRACE:%d* message\n*DEBUG:%d* message\n*INFO:%d* message\n*HTML:%d* message\n', twarn, ttrace, tdebug, tinfo, thtml),
9595
status: 'PASS',
@@ -111,9 +111,9 @@ describe('Robot Remote Library', function () {
111111
}
112112
};
113113
server = new robot.Server([lib], {host: 'localhost', port: serverPort, allowStop: true}, function () {
114-
robot.createClient({host: 'localhost', port: serverPort}).done(
114+
robot.createClient({host: 'localhost', port: serverPort}).then(
115115
function (val) {
116-
val.testKeyword().done(done, function (err) {
116+
val.testKeyword().then(done, function (err) {
117117
assert.equal(true, err.continuable);
118118
assert.equal(true, err.fatal);
119119
done();
@@ -135,11 +135,11 @@ describe('Robot Remote Library', function () {
135135
}
136136
};
137137
server = new robot.Server([lib1, lib2], {host: 'localhost', port: serverPort, allowStop: true}, function () {
138-
robot.createClient({host: 'localhost', port: serverPort}).done(
138+
robot.createClient({host: 'localhost', port: serverPort}).then(
139139
function (val) {
140-
val.testKeywordFromLib1().done(function () {
140+
val.testKeywordFromLib1().then(function () {
141141
}, done);
142-
val.testKeywordFromLib2().done(function (val) {
142+
val.testKeywordFromLib2().then(function (val) {
143143
done();
144144
}, done);
145145
}, done

test/testlibrary.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

3-
var assert = require('assert'),
4-
Promise = require('promise');
3+
var assert = require('assert');
54

65
var lib = module.exports;
76

0 commit comments

Comments
 (0)