Skip to content

Commit

Permalink
Add function to custom resolve the CLI path
Browse files Browse the repository at this point in the history
  • Loading branch information
rmenezes committed Sep 5, 2024
1 parent 575568e commit 6b84f50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cli/src/connect/parser_executables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getGradleWrapperPath,
} from '../parser_scripts/get_gradlew_path'
import { getComposeErrorSuggestion } from '../parser_scripts/compose_errors'
import { getCustomSwiftCLIPath } from '../parser_scripts/get_custom_swift_parse'

const temporaryInputFilePath = 'tmp/figma-code-connect-parser-input.json.tmp'

Expand All @@ -35,7 +36,8 @@ const FIRST_PARTY_PARSERS: Record<FirstPartyExecutableParser, ParserInfo> = {
swift: {
command: async (cwd, config, mode) => {
if (config.customSwiftCLIPath) {
return `${config.customSwiftCLIPath}`
const customCLIPath = path.join(getCustomSwiftCLIPath(cwd), `${config.customSwiftCLIPath}`)
return customCLIPath
} else {
return `swift run --package-path ${await getSwiftParserDir(cwd, (config as any).xcodeprojPath)} figma-swift`
}
Expand Down
6 changes: 6 additions & 0 deletions cli/src/parser_scripts/get_custom_swift_parse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { execSync } from 'child_process'

// Check if a file matching a search pattern exists, and return the first match if so
export function getCustomSwiftCLIPath(cwd: string) {
return execSync(`pwd `, { cwd }).toString().trim().split('\n')[0]
}

0 comments on commit 6b84f50

Please sign in to comment.