Skip to content

Commit de7bc9b

Browse files
committed
Added —assets flag to perspective-cli
1 parent 287a2ce commit de7bc9b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/perspective-cli/src/js/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*/
99

10-
const {WebSocketHost, table} = require("@jpmorganchase/perspective/build/perspective.node.js");
10+
const {WebSocketHost, table} = require("@jpmorganchase/perspective");
1111
const {read_stdin, open_browser} = require("./utils.js");
1212
const fs = require("fs");
1313
const path = require("path");
@@ -66,8 +66,11 @@ async function convert(filename, options) {
6666
* @param {*} options
6767
*/
6868
async function host(filename, options) {
69-
const files = path.join(__dirname, "html");
70-
const server = new WebSocketHost({assets: [files], port: options.port});
69+
let files = [path.join(__dirname, "html")];
70+
if (options.assets) {
71+
files = [options.assets, ...files];
72+
}
73+
const server = new WebSocketHost({assets: files, port: options.port});
7174
let file;
7275
if (filename) {
7376
file = fs.readFileSync(filename).toString();
@@ -96,6 +99,7 @@ program
9699
.command("host [filename]")
97100
.description("Host a file on a local Websocket/HTTP server using a server-side Perspective. Reads from STDIN if no filename is provided")
98101
.option("-p, --port <port>", "Which port to bind to.", x => parseInt(x), 8080)
102+
.option("-a, --assets <path>", "Host from a working directory")
99103
.option("-o, --open", "Open a browser automagically.")
100104
.action(host);
101105

0 commit comments

Comments
 (0)