1- import { existsSync , mkdirSync , readFileSync , writeFileSync , unlinkSync , chmodSync , appendFileSync } from "node:fs" ;
2- import { dirname , join } from "node:path" ;
1+ import {
2+ appendFileSync ,
3+ chmodSync ,
4+ existsSync ,
5+ mkdirSync ,
6+ readFileSync ,
7+ unlinkSync ,
8+ writeFileSync ,
9+ } from "node:fs" ;
310import { homedir } from "node:os" ;
11+ import { join } from "node:path" ;
412
5- export type AliasStorageLocation = "shell-config" | "usr-local-bin" | "home-bin" ;
13+ export type AliasStorageLocation =
14+ | "shell-config"
15+ | "usr-local-bin"
16+ | "home-bin" ;
617
718export interface AliasConfig {
819 aliases : Record < string , AliasEntry > ;
@@ -55,7 +66,12 @@ export function saveAliasConfig(config: AliasConfig): void {
5566}
5667
5768export function getInstanceDataDir ( instanceName : string ) : string {
58- return join ( homedir ( ) , "Library" , "Application Support" , instanceName . replace ( / / g, "" ) ) ;
69+ return join (
70+ homedir ( ) ,
71+ "Library" ,
72+ "Application Support" ,
73+ instanceName . replace ( / / g, "" )
74+ ) ;
5975}
6076
6177export function getInstanceAppPath ( instanceName : string ) : string {
@@ -92,7 +108,10 @@ open -n "\$APP_PATH" --args --user-data-dir "\$DATA_DIR" "\$DIR"
92108` ;
93109}
94110
95- function generateShellFunction ( aliasName : string , instanceName : string ) : string {
111+ function generateShellFunction (
112+ aliasName : string ,
113+ instanceName : string
114+ ) : string {
96115 const dataDir = getInstanceDataDir ( instanceName ) ;
97116 const appPath = getInstanceAppPath ( instanceName ) ;
98117
@@ -182,7 +201,10 @@ export function createShellAlias(
182201 appendFileSync ( shellConfigPath , functionContent , "utf-8" ) ;
183202}
184203
185- export function removeShellAlias ( aliasName : string , shellConfigPath : string ) : boolean {
204+ export function removeShellAlias (
205+ aliasName : string ,
206+ shellConfigPath : string
207+ ) : boolean {
186208 if ( ! existsSync ( shellConfigPath ) ) {
187209 return false ;
188210 }
@@ -250,11 +272,19 @@ export function createAlias(options: CreateAliasOptions): CreateAliasResult {
250272 break ;
251273 }
252274 case "usr-local-bin" : {
253- scriptPath = createExecutableScript ( aliasName , instanceName , getUsrLocalBinDir ( ) ) ;
275+ scriptPath = createExecutableScript (
276+ aliasName ,
277+ instanceName ,
278+ getUsrLocalBinDir ( )
279+ ) ;
254280 break ;
255281 }
256282 case "home-bin" : {
257- scriptPath = createExecutableScript ( aliasName , instanceName , getHomeBinDir ( ) ) ;
283+ scriptPath = createExecutableScript (
284+ aliasName ,
285+ instanceName ,
286+ getHomeBinDir ( )
287+ ) ;
258288 break ;
259289 }
260290 }
@@ -349,7 +379,9 @@ export function generateAliasName(instanceName: string): string {
349379 . replace ( / ^ - | - $ / g, "" ) ;
350380}
351381
352- export function getStorageLocationLabel ( location : AliasStorageLocation ) : string {
382+ export function getStorageLocationLabel (
383+ location : AliasStorageLocation
384+ ) : string {
353385 switch ( location ) {
354386 case "shell-config" :
355387 return "Shell config (~/.zshrc or ~/.bashrc)" ;
@@ -363,7 +395,9 @@ export function getStorageLocationLabel(location: AliasStorageLocation): string
363395export function isHomeBinInPath ( ) : boolean {
364396 const pathEnv = process . env . PATH ?? "" ;
365397 const homeBin = getHomeBinDir ( ) ;
366- return pathEnv . split ( ":" ) . some ( ( p ) => p === homeBin || p === "~/bin" || p === "$HOME/bin" ) ;
398+ return pathEnv
399+ . split ( ":" )
400+ . some ( ( p ) => p === homeBin || p === "~/bin" || p === "$HOME/bin" ) ;
367401}
368402
369403export function getPathSetupInstructions ( ) : string {
@@ -376,4 +410,3 @@ export PATH="$HOME/bin:$PATH"
376410
377411Then restart your terminal or run: source ${ configFile } ` ;
378412}
379-
0 commit comments