UNPKG

codetainer

Version:

A clean and simple CLI to manage and store code snippets with ease.

16 lines (13 loc) 419 B
import { exec } from "child_process"; function openFile(filePath) { const platform = process.platform; if (platform === "win32") { // Uses default app for the file type (safe, no PowerShell) exec(`start "" "${filePath.replace(/\\/g, "\\\\")}"`); } else if (platform === "darwin") { exec(`open "${filePath}"`); } else { exec(`xdg-open "${filePath}"`); } } export { openFile };