From 0c153fdd6b899d75cfb7aa4d0529e39a26c36ff8 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 11 Mar 2024 21:12:54 +0800 Subject: [PATCH] Add support for `--target=` (#248) Closes #240 --- dist/index.js | 13 +++++++++---- src/index.ts | 12 ++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 913a883..92e424d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11480,7 +11480,7 @@ function getRustTarget(args) { var _a, _b, _c; let target = core.getInput('target'); if (!target && args.length > 0) { - const val = getCliValue(args, '--target'); + const val = getCliValue(args, '--target') || getCliValue(args, '--target='); if (val && val.length > 0) { target = val; } @@ -11560,8 +11560,13 @@ async function getRustToolchain(args) { } function getCliValue(args, key) { const index = args.indexOf(key); - if (index !== -1 && args[index + 1] !== undefined) { - return args[index + 1]; + if (index !== -1) { + if (key.endsWith('=')) { + return args[index].slice(key.length); + } + else if (args[index + 1] !== undefined) { + return args[index + 1]; + } } return undefined; } @@ -11629,7 +11634,7 @@ async function findVersion(args) { } } else { - core.info('No pyproject.toml found at ${pyprojectToml}, fallback to latest'); + core.info(`No pyproject.toml found at ${pyprojectToml}, fallback to latest`); version = 'latest'; } } diff --git a/src/index.ts b/src/index.ts index c308c70..e3bb735 100644 --- a/src/index.ts +++ b/src/index.ts @@ -159,7 +159,7 @@ function hasZigSupport(target: string): boolean { function getRustTarget(args: string[]): string { let target = core.getInput('target') if (!target && args.length > 0) { - const val = getCliValue(args, '--target') + const val = getCliValue(args, '--target') || getCliValue(args, '--target=') if (val && val.length > 0) { target = val } @@ -246,8 +246,12 @@ async function getRustToolchain(args: string[]): Promise { function getCliValue(args: string[], key: string): string | undefined { const index = args.indexOf(key) - if (index !== -1 && args[index + 1] !== undefined) { - return args[index + 1] + if (index !== -1) { + if (key.endsWith('=')) { + return args[index].slice(key.length) + } else if (args[index + 1] !== undefined) { + return args[index + 1] + } } return undefined } @@ -350,7 +354,7 @@ async function findVersion(args: string[]): Promise { } } else { core.info( - 'No pyproject.toml found at ${pyprojectToml}, fallback to latest' + `No pyproject.toml found at ${pyprojectToml}, fallback to latest` ) version = 'latest' }