Skip to content

Commit 6b84f50

Browse files
committedSep 5, 2024
Add function to custom resolve the CLI path
1 parent 575568e commit 6b84f50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎cli/src/connect/parser_executables.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
getGradleWrapperPath,
2020
} from '../parser_scripts/get_gradlew_path'
2121
import { getComposeErrorSuggestion } from '../parser_scripts/compose_errors'
22+
import { getCustomSwiftCLIPath } from '../parser_scripts/get_custom_swift_parse'
2223

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

@@ -35,7 +36,8 @@ const FIRST_PARTY_PARSERS: Record<FirstPartyExecutableParser, ParserInfo> = {
3536
swift: {
3637
command: async (cwd, config, mode) => {
3738
if (config.customSwiftCLIPath) {
38-
return `${config.customSwiftCLIPath}`
39+
const customCLIPath = path.join(getCustomSwiftCLIPath(cwd), `${config.customSwiftCLIPath}`)
40+
return customCLIPath
3941
} else {
4042
return `swift run --package-path ${await getSwiftParserDir(cwd, (config as any).xcodeprojPath)} figma-swift`
4143
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { execSync } from 'child_process'
2+
3+
// Check if a file matching a search pattern exists, and return the first match if so
4+
export function getCustomSwiftCLIPath(cwd: string) {
5+
return execSync(`pwd `, { cwd }).toString().trim().split('\n')[0]
6+
}

0 commit comments

Comments
 (0)