Skip to content

Commit b02fd6d

Browse files
authored
Check if root directory exists and is a directory (lukejacksonn#61)
1 parent a18ccbf commit b02fd6d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

servor.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ module.exports = async ({
3737

3838
root = root.startsWith('/') ? root : path.join(process.cwd(), root);
3939

40+
if (!fs.existsSync(root)) {
41+
console.log(`[ERR] Root directory ${root} does not exist!`);
42+
process.exit();
43+
}
44+
45+
if (!fs.statSync(root).isDirectory()) {
46+
console.log(`[ERR] Root directory "${root}" is not directory!`);
47+
process.exit();
48+
}
49+
4050
const reloadClients = [];
4151
const protocol = credentials ? 'https' : 'http';
4252
const server = credentials

0 commit comments

Comments
 (0)