diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-13 21:54:52 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-13 21:54:52 -0300 |
commit | 4ea5e57d2b6c12f42ff21c4b43056021553f07a0 (patch) | |
tree | 175c5c662639496fc859fa9a4852c363a6bab11d /socat.js | |
parent | 84c49e453336d6105655edd08e93bab071c0fc3b (diff) | |
parent | a36e372ba88b59e08fa938f76b261fdc2797bef2 (diff) |
Merge branch 'main' into socket-mtui
And also get most of it working wow.
Diffstat (limited to 'socat.js')
-rw-r--r-- | socat.js | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/socat.js b/socat.js index 8871c7e..a465a73 100644 --- a/socat.js +++ b/socat.js @@ -2,16 +2,14 @@ // Assumes access to the `socat` command as a child process; if it's not // present, it will fall back to just writing to the specified file. -const EventEmitter = require('events') -const { spawn } = require('child_process') -const { killProcess, commandExists } = require('./general-util') -const { promisify } = require('util') -const fs = require('fs') -const path = require('path') +import {spawn} from 'node:child_process' +import {writeFile} from 'node:fs/promises' +import EventEmitter from 'node:events' +import path from 'node:path' -const writeFile = promisify(fs.writeFile) +import {killProcess, commandExists} from './general-util.js' -module.exports = class Socat extends EventEmitter { +export default class Socat extends EventEmitter { constructor(path) { super() this.setPath(path) @@ -30,7 +28,7 @@ module.exports = class Socat extends EventEmitter { this.subprocess.on('close', () => { this.subprocess = null }) - this.subprocess.stdin.on('error', err => { + this.subprocess.stdin.on('error', () => { this.stop() }) } @@ -69,7 +67,7 @@ module.exports = class Socat extends EventEmitter { } } else { try { - await writeFile(path.resolve(__dirname, this.path), message + '\r\n') + await writeFile(path.resolve(process.cwd(), this.path), message + '\r\n') } catch (error) { // :shrug: We tried! // -- It's possible to get here if the specified path isn't an actual |