patha
Version:
File paths library. All you need to work with paths. Tiny drop-in replacement for 'path'. Works in Node, Browser, and Deno.
22 lines (21 loc) • 594 B
text/typescript
/**
* Add bin extension to the given binary name.
*
* @example
*
* ```js
* import { addExeExt } from "patha"
*
* addExeExt("path/to/file-name") // gives "path/to/file-name.exe" on Windows and "path/to/file-name" on others
* ```
*
* @param name The name you want to add the shell extension to
* @param win_ext Defaults to `.exe` on Windows
* @param other_ext Defaults to `""` On other platforms.
*/
export function addExeExt(name: string, win_ext = ".exe", other_ext = "") {
if (process.platform === "win32") {
return `${name}${win_ext}`
}
return `${name}${other_ext}`
}