Skip to content

Commit

Permalink
deps: update Prettier and fix configs
Browse files Browse the repository at this point in the history
PR-URL: #409
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Dmytro Nechai <nechaido@gmail.com>
Reviewed-By: Timur Shemsedinov <timur.shemsedinov@gmail.com>
  • Loading branch information
belochub committed Jan 22, 2019
1 parent a0b20de commit 1063eda
Show file tree
Hide file tree
Showing 37 changed files with 493 additions and 767 deletions.
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"presets": ["@babel/env"],
"plugins": [
"@babel/plugin-transform-runtime"
],
"plugins": ["@babel/plugin-transform-runtime"],
"sourceType": "script"
}
8 changes: 7 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"overrides": [
{
"files": [".babelrc", ".eslintrc", ".prettierrc", ".remarkrc"],
"options": { "parser": "json" }
}
]
}
19 changes: 6 additions & 13 deletions lib/cli/line-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,13 @@ module.exports = class LineProcessor {
return;
}
const interfaces = args[2] ? utils.split(args[2], ' ') : [];
this.commandProcessor.connect(
scheme,
host,
port,
app,
interfaces,
err => {
if (err) {
callback(err);
return;
}
callback(null, 'Connection established');
this.commandProcessor.connect(scheme, host, port, app, interfaces, err => {
if (err) {
callback(err);
return;
}
);
callback(null, 'Connection established');
});
}

disconnect(_, callback) {
Expand Down
23 changes: 15 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"eslint-config-prettier": "^2.10.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-prettier": "^2.7.0",
"prettier": "^1.14.0",
"prettier": "1.16.x",
"remark-cli": "^6.0.1",
"remark-preset-lint-metarhia": "^1.0.4",
"remark-validate-links": "^8.0.0",
Expand All @@ -69,8 +69,8 @@
"test-node": "node tools/run-node-tests.js",
"test-integration": "node test/integration/run.js",
"test-coverage": "nyc npm run test-node",
"lint": "eslint . && remark . && prettier --debug-check \"**/*.js\" \"**/*.json\" \"**/*.md\" .eslintrc .prettierrc",
"fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" .eslintrc .prettierrc",
"lint": "eslint . && remark . && prettier -c \"**/*.js\" \"**/*.json\" \"**/*.md\" \".*rc\" \"**/*.yml\"",
"fmt": "prettier --write \"**/*.js\" \"**/*.json\" \"**/*.md\" \".*rc\" \"**/*.yml\"",
"build-browser": "webpack --progress",
"prepublish": "npm run -s build-browser"
},
Expand Down
157 changes: 61 additions & 96 deletions test/node/api-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,15 @@ test.test('must call latest version if no version specified', test => {
server.listen(0, () => {
const port = server.address().port;
const appLatest = { name: app.name };
jstp.net.connect(
appLatest,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
}
);
jstp.net.connect(appLatest, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
});
});
});

Expand All @@ -90,20 +85,15 @@ test.test('must call specific version when specified (v1)', test => {
server.listen(0, () => {
const port = server.address().port;
const appV1 = { name: app.name, version: '1' };
jstp.net.connect(
appV1,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 42);
test.end();
});
}
);
jstp.net.connect(appV1, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 42);
test.end();
});
});
});
});

Expand All @@ -116,20 +106,15 @@ test.test('must call specific version when specified (v2)', test => {
server.listen(0, () => {
const port = server.address().port;
const appV2 = { name: app.name, version: '2' };
jstp.net.connect(
appV2,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
}
);
jstp.net.connect(appV2, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
});
});
});

Expand All @@ -143,20 +128,15 @@ test.test('must handle version ranges (^1.0.0)', test => {
const port = server.address().port;
const appV1Compatible = { name: app.name, version: '^1.0.0' };
// must connect to appV1
jstp.net.connect(
appV1Compatible,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 42);
test.end();
});
}
);
jstp.net.connect(appV1Compatible, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 42);
test.end();
});
});
});
});

Expand All @@ -170,20 +150,15 @@ test.test('must handle version ranges (>1.0.0)', test => {
const port = server.address().port;
const appV1Higher = { name: app.name, version: '>1.0.0' };
// must connect to appV2
jstp.net.connect(
appV1Higher,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
}
);
jstp.net.connect(appV1Higher, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'connect must not return an error');
connection.callMethod('calculator', 'answer', [], (error, result) => {
test.assertNot(error, 'callMethod must not return an error');
test.strictSame(result, 24);
test.end();
});
});
});
});

Expand All @@ -196,21 +171,16 @@ test.test('must return an error on connect to nonexistent version', test => {
server.listen(0, () => {
const port = server.address().port;
const nonexistentApp = { name: app.name, version: '9999' };
jstp.net.connect(
nonexistentApp,
null,
port,
(error, conn) => {
connection = conn;
test.assert(error, 'connect must return an error');
test.equal(
error.code,
jstp.ERR_APP_NOT_FOUND,
'error must be an ERR_APP_NOT_FOUND'
);
test.end();
}
);
jstp.net.connect(nonexistentApp, null, port, (error, conn) => {
connection = conn;
test.assert(error, 'connect must return an error');
test.equal(
error.code,
jstp.ERR_APP_NOT_FOUND,
'error must be an ERR_APP_NOT_FOUND'
);
test.end();
});
});
});

Expand All @@ -223,17 +193,12 @@ test.test('must return an error on connect to invalid version', test => {
server.listen(0, () => {
const port = server.address().port;
const application = { name: app.name, version: '__invalid_version__' };
jstp.net.connect(
application,
null,
port,
(error, conn) => {
connection = conn;
test.assert(error, 'connect must return an error');
test.equal(error.message, 'Invalid semver version range');
test.end();
}
);
jstp.net.connect(application, null, port, (error, conn) => {
connection = conn;
test.assert(error, 'connect must return an error');
test.equal(error.message, 'Invalid semver version range');
test.end();
});
});
});

Expand Down
15 changes: 5 additions & 10 deletions test/node/application-event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@ test.test('must call event handler in application on remote event', test => {
server = jstp.net.createServer([application]);
server.listen(0, () => {
const port = server.address().port;
jstp.net.connect(
app.name,
null,
port,
(error, conn) => {
connection = conn;
test.assertNot(error, 'must connect to server and perform handshake');
connection.emitRemoteEvent('someService', 'name', [expectedName]);
}
);
jstp.net.connect(app.name, null, port, (error, conn) => {
connection = conn;
test.assertNot(error, 'must connect to server and perform handshake');
connection.emitRemoteEvent('someService', 'name', [expectedName]);
});
});
});
16 changes: 5 additions & 11 deletions test/node/connection-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@ test.beforeEach(done => {
server = jstp.net.createServer(serverConfig);
server.listen(0, () => {
const port = server.address().port;
jstp.net.connect(
app.name,
null,
port,
'localhost',
(error, conn) => {
test.assertNot(error, 'must connect to server and perform handshake');
connection = conn;
done();
}
);
jstp.net.connect(app.name, null, port, 'localhost', (error, conn) => {
test.assertNot(error, 'must connect to server and perform handshake');
connection = conn;
done();
});
});
});

Expand Down
Loading

0 comments on commit 1063eda

Please sign in to comment.