Skip to content

Commit 719873f

Browse files
committed
feat: Remove unused options
1 parent 41cdc2b commit 719873f

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/commands/server.ts

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { execSync } from 'node:child_process';
1+
import fs from 'node:fs';
22
import express from 'express';
3-
import chokidar from 'chokidar';
43

54
/**
6-
* Host a static local server using the specified directory as root
5+
* Starts a static local server
76
* @param root Root directory
87
* @param options Server options
98
*/
@@ -12,27 +11,15 @@ function server(root: string, options: {
1211
* Port to listen on
1312
*/
1413
port: number;
15-
/**
16-
* Watch directory
17-
*/
18-
watch?: string;
19-
/**
20-
* Command to run on change
21-
*/
22-
command?: string;
2314
}) {
15+
if(!fs.lstatSync(root).isDirectory())
16+
throw new Error('Root must be a directory');
17+
2418
const app = express();
2519
app.use(express.static(root));
2620
app.listen(options.port, () => {
2721
console.log(`Server is listening on http://localhost:${options.port}/`);
2822
});
29-
30-
chokidar.watch(options.watch ?? root).on('change', (path) => {
31-
if(options.command)
32-
execSync(options.command.replace(/\$path/g, path), {
33-
stdio: 'inherit',
34-
});
35-
});
3623
}
3724

3825
export default server;

0 commit comments

Comments
 (0)