Skip to content

Commit

Permalink
fix a package export
Browse files Browse the repository at this point in the history
  • Loading branch information
williamstein committed Aug 25, 2023
1 parent 8fa2dd2 commit 7190675
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions websocket-sftp/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "websocket-sftp",
"version": "0.5.0",
"version": "0.5.1",
"description": "The sftp protocol, over a WebSocket",
"main": "./dist/lib/sftp.js",
"exports": {
".": "./dist/lib/sftp.js",
"./*": "./dist/*.js"
"./lib/*": "./dist/lib/*.js"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
16 changes: 10 additions & 6 deletions websocketfs/lib/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@ export default async function serve({
path,
host = "localhost",
port,
noServer,
options,
}: {
path: string;
host?: string;
port?: number;
noServer?: boolean;
options?: any;
}): Promise<{ port: number; server: SftpServer }> {
if (port == null) {
}): Promise<{ port?: number; server: SftpServer }> {
if (port == null && !noServer) {
// get an available port
port = await getPort();
}
if (port == null) {
throw Error("bug");
}

// start SFTP server on localhost
const server = new SftpServer({
...options,
noServer,
host,
port,
virtualRoot: path,
});
log("SFTP server listening on port ", port);
if (!noServer) {
log("Created Sftp server listening on port ", port);
} else {
log("Created Sftp websocket server but no http server");
}

return { port, server };
}

0 comments on commit 7190675

Please sign in to comment.