Skip to content

Commit

Permalink
fix(php|artisan): resolve promises correctly (withfig#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
timboozle authored Jul 30, 2024
1 parent f0bdcb1 commit 8fa2e6a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
12 changes: 6 additions & 6 deletions src/php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ const completionSpec: Fig.Spec = {
const subcommands = [];

await Promise.all([
async () => {
(async () => {
if (await fileExists(executeShellCommand, "artisan")) {
subcommands.push({ name: "artisan", loadSpec: "php/artisan" });
}
},
async () => {
})(),
(async () => {
if (await fileExists(executeShellCommand, "please")) {
subcommands.push({ name: "please", loadSpec: "php/please" });
}
},
async () => {
})(),
(async () => {
if (await fileExists(executeShellCommand, "bin/console")) {
subcommands.push({
name: "bin/console",
loadSpec: "php/bin-console",
});
}
},
})(),
]);

return {
Expand Down
56 changes: 31 additions & 25 deletions src/php/artisan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,41 @@ const completionSpec: Fig.Spec = {
try {
const commandDefinition = JSON.parse(stdout);

commandDefinition.commands.map((command) => {
subcommands.push({
name: command.name,
description: command.description,
icon: "https://web.tinkerwell.app/img/laravel.3cab6a56.png",
args: Object.keys(command.definition.arguments).map((argumentKey) => {
const argument = command.definition.arguments[argumentKey];
commandDefinition.commands
.filter((command) => command.name !== "_complete")
.map((command) => {
subcommands.push({
name: command.name,
description: command.description,
icon: "https://web.tinkerwell.app/img/laravel.3cab6a56.png",
args: Object.keys(command.definition.arguments).map(
(argumentKey) => {
const argument = command.definition.arguments[argumentKey];

return {
name: argument.name,
description: argument.description,
isOptional: !argument.is_required,
};
}),
options: Object.keys(command.definition.options).map((optionKey) => {
const option = command.definition.options[optionKey];
const names = [option.name];
return {
name: argument.name,
description: argument.description,
isOptional: !argument.is_required,
};
}
),
options: Object.keys(command.definition.options).map(
(optionKey) => {
const option = command.definition.options[optionKey];
const names = [option.name];

if (option.shortcut !== "") {
names.push(option.shortcut);
}
if (option.shortcut !== "") {
names.push(option.shortcut);
}

return {
name: names,
description: option.description,
};
}),
return {
name: names,
description: option.description,
};
}
),
});
});
});
} catch (err) {
//
}
Expand Down

0 comments on commit 8fa2e6a

Please sign in to comment.