Skip to content

Commit 25c1bcc

Browse files
author
Isaac Ramirez
committed
- change summary:
- create client script to run a test client - upate test.client sample
1 parent 21f6be4 commit 25c1bcc

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

client

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const { sync } = require('glob')
4+
5+
const [clientName, ...args] = process.argv.slice(2)
6+
7+
const globOptions = { realpath: true, cwd: __dirname }
8+
9+
const files = sync('src/**/*.client.js', globOptions)
10+
11+
const clients = files.reduce((modules, path) => Object.assign(modules, require(path)), {})
12+
13+
if (!clients[clientName]) {
14+
throw new ReferenceError(`Client '${clientName}' not found.`)
15+
}
16+
17+
clients[clientName].main(args)

docs/samples/test.client.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
/** @module samples */
1+
/** @module TestClients */
22

3-
const { StdOut } = require('../src/libs')
3+
const { StdOut } = require('../../src/libs')
44

55
/**
6-
* @summary Client
7-
* @classdesc A Test Client
8-
* @page n
6+
* An example of a TestClient class.
7+
* @memberof module:TestClients
8+
* @see page: n.
9+
* @see [edu.princeton.cs.algs4.CLASS_NAME.java]{@link https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/CLASS_NAME.java.html}
910
*/
10-
class Client {
11+
class TestClient {
1112
/**
1213
* Main static function
1314
* @param {[number, number]} args - [n, m]
1415
* @returns {number} `n` * `m`
1516
* @example <caption>testing the client</caption>
1617
* ```sh
17-
* $ node test.client.js 10 50
18+
* $ ./client TestClient 10 50
1819
* 500
1920
* ```
2021
*/
@@ -25,3 +26,5 @@ class Client {
2526
StdOut.println(n * m)
2627
}
2728
}
29+
30+
module.exports = { TestClient }

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
},
3333
"devDependencies": {
3434
"d3": "^5.15.1",
35+
"glob": "^7.1.6",
3536
"ink-docstrap": "^1.3.2",
3637
"jasmine": "^3.6.3",
3738
"jsdoc": "~3.6.6",

0 commit comments

Comments
 (0)