27 lines
394 B
JavaScript
27 lines
394 B
JavaScript
import fs from 'node:fs';
|
|
|
|
export class Unix_Socket {
|
|
constructor(path) {
|
|
Object.assign(this, { path });
|
|
}
|
|
|
|
get connect_options() {
|
|
const { path } = this;
|
|
return { path };
|
|
}
|
|
|
|
listen(server, on_listening) {
|
|
const { path } = this;
|
|
if (fs.existsSync(path)) {
|
|
fs.unlinkSync(path);
|
|
}
|
|
|
|
server.listen(path, () => {
|
|
fs.chmodSync(path, 0o666);
|
|
on_listening?.();
|
|
});
|
|
|
|
}
|
|
|
|
|
|
} |