|
16 | 16 | ----------------------------------------------------------------------------*/
|
17 | 17 |
|
18 | 18 | import assert from 'assert';
|
19 |
| -import commandExists from 'command-exists'; |
20 | 19 | import * as vscode from 'vscode';
|
21 | 20 | import { CMD_GPR_PROJECT_ARGS } from './commands';
|
22 | 21 | import { adaExtState } from './extension';
|
@@ -545,6 +544,11 @@ export class SimpleTaskProvider implements vscode.TaskProvider {
|
545 | 544 | }
|
546 | 545 | }
|
547 | 546 |
|
| 547 | +/** |
| 548 | + * |
| 549 | + * @returns true if ALIRE should be used for task execution, i.e. when the |
| 550 | + * workspace contains a `alire.toml` file. |
| 551 | + */ |
548 | 552 | async function useAlire() {
|
549 | 553 | return (await adaExtState.getAlireTomls()).length > 0;
|
550 | 554 | }
|
@@ -643,18 +647,6 @@ function isEmptyArray(obj: unknown): boolean {
|
643 | 647 | return false;
|
644 | 648 | }
|
645 | 649 |
|
646 |
| -// Alire `exec` command if we have `alr` installed and `alire.toml` |
647 |
| -export async function alire(): Promise<string[]> { |
648 |
| - return vscode.workspace.findFiles('alire.toml').then((found) => |
649 |
| - found.length == 0 |
650 |
| - ? [] // not alire.toml found, return no command |
651 |
| - : // if alire.toml found, search for `alr` |
652 |
| - commandExists('alr') |
653 |
| - .then(() => ['alr', 'exec', '--']) |
654 |
| - .catch(() => []) |
655 |
| - ); |
656 |
| -} |
657 |
| - |
658 | 650 | export function registerTaskProviders() {
|
659 | 651 | return [
|
660 | 652 | vscode.tasks.registerTaskProvider(TASK_TYPE_ADA, createAdaTaskProvider()),
|
@@ -1004,6 +996,17 @@ export async function findBuildMainTask(adaMain: AdaMain): Promise<vscode.Task |
|
1004 | 996 | );
|
1005 | 997 | }
|
1006 | 998 |
|
| 999 | +/** |
| 1000 | + * Create an updated task that uses the `alr` executable. |
| 1001 | + * |
| 1002 | + * If the task matches the pre-defined tasks for building and cleaning the project, |
| 1003 | + * then the commands used will be respectively `alr build` and `alr clean`. |
| 1004 | + * |
| 1005 | + * Otherwise `alr exec -- ...` is used. |
| 1006 | + * |
| 1007 | + * @param taskDef - a task definition to update to ALIRE |
| 1008 | + * @returns a copy of the given task where the `alr` executable is used. |
| 1009 | + */ |
1007 | 1010 | function updateToAlire(taskDef: SimpleTaskDef): SimpleTaskDef {
|
1008 | 1011 | /**
|
1009 | 1012 | * Only process shell command tasks, if they are not already using ALIRE
|
|
0 commit comments