Skip to content

Commit

Permalink
Add support for --target= (#248)
Browse files Browse the repository at this point in the history
Closes #240
  • Loading branch information
messense authored Mar 11, 2024
1 parent 0114ebe commit 0c153fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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';
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -246,8 +246,12 @@ async function getRustToolchain(args: string[]): Promise<string> {

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
}
Expand Down Expand Up @@ -350,7 +354,7 @@ async function findVersion(args: string[]): Promise<string> {
}
} else {
core.info(
'No pyproject.toml found at ${pyprojectToml}, fallback to latest'
`No pyproject.toml found at ${pyprojectToml}, fallback to latest`
)
version = 'latest'
}
Expand Down

0 comments on commit 0c153fd

Please sign in to comment.