« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/socat.js
diff options
context:
space:
mode:
Diffstat (limited to 'socat.js')
-rw-r--r--socat.js18
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