From 32f9dd549595aaa300af8239555123d0f6c46ab7 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 9 Jun 2026 20:33:31 -0400 Subject: [PATCH] refactor(tts): replace string interpolation with path.join() --- tts.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tts.ts b/tts.ts index 8af1144..907a05c 100644 --- a/tts.ts +++ b/tts.ts @@ -1,5 +1,6 @@ import fs from "node:fs/promises"; import os from "node:os"; +import path from "node:path"; import process from "node:process"; import { createInterface } from "node:readline"; import { parseArgs } from "node:util"; @@ -60,13 +61,13 @@ async function main() { } const home = os.homedir(); - const cwd = `${home}/.ttsc/`; + const cwd = path.join(home, ".ttsc"); - const wavs = await Array.fromAsync(fs.glob(`${cwd}*.wav`)); + const wavs = await Array.fromAsync(fs.glob(path.join(cwd, "*.wav"))); await execa({ cwd, shell: true, reject: false })`rm ${wavs}`; if (edit) { - const file = `${cwd}input.txt`; + const file = path.join(cwd, "input.txt"); await fs.writeFile(file, input); const editor = process.env.EDITOR || "nano"; await execa({ @@ -124,7 +125,7 @@ async function main() { const [columns] = process.stdout.getWindowSize(); const text = wrapAnsi(info.text, columns); - const file = `${home}/.ttsc/${info.file}.wav`; + const file = path.join(cwd, `${info.file}.wav`); if (wait) { process.stdout.write("."); @@ -148,7 +149,7 @@ async function main() { console.log(chalk.yellow(`Combining audio with sox...\n`)); try { - const wavs = await Array.fromAsync(fs.glob(`${cwd}*.wav`)); + const wavs = await Array.fromAsync(fs.glob(path.join(cwd, "*.wav"))); await execa({ cwd, shell: true })`sox ${wavs} output.wav`; } catch (err) { if (err instanceof Object && "code" in err && err.code === "ENOENT") { @@ -163,7 +164,9 @@ async function main() { const [columns] = process.stdout.getWindowSize(); console.log(wrapAnsi(input, columns)); - console.log(chalk.green(`Playing audio from ${cwd}output.wav`)); + console.log( + chalk.green(`Playing audio from ${path.join(cwd, "output.wav")}`), + ); await execa({ cwd, stdin: "ignore",