-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #399 from leoafarias/feature/exec-command
Implementing exec command
- Loading branch information
Showing
9 changed files
with
119 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:args/args.dart'; | ||
import 'package:args/command_runner.dart'; | ||
|
||
import '../models/valid_version_model.dart'; | ||
import '../services/cache_service.dart'; | ||
import '../services/project_service.dart'; | ||
import '../utils/commands.dart'; | ||
import '../utils/logger.dart'; | ||
import '../workflows/ensure_cache.workflow.dart'; | ||
import 'base_command.dart'; | ||
|
||
/// Executes scripts with the configured Flutter SDK | ||
class ExecCommand extends BaseCommand { | ||
@override | ||
final name = 'exec'; | ||
@override | ||
final description = 'Executes scripts with the configured Flutter SDK'; | ||
@override | ||
final argParser = ArgParser.allowAnything(); | ||
|
||
/// Constructor | ||
ExecCommand(); | ||
|
||
@override | ||
Future<int> run() async { | ||
final version = await ProjectService.findVersion(); | ||
|
||
if (argResults!.rest.isEmpty) { | ||
throw UsageException( | ||
'No command was provided to be executed', | ||
usage, | ||
); | ||
} | ||
|
||
final cmd = argResults!.rest[0]; | ||
|
||
// Removes version from first arg | ||
final execArgs = [...argResults!.rest]..removeAt(0); | ||
|
||
if (version != null) { | ||
final validVersion = ValidVersion(version); | ||
// Will install version if not already instaled | ||
final cacheVersion = await ensureCacheWorkflow(validVersion); | ||
|
||
logger.trace('fvm: running version "$version"\n'); | ||
// If its not a channel silence version check | ||
|
||
// Runs exec command with pinned version | ||
return await execCmd(cmd, cacheVersion, execArgs); | ||
} else { | ||
// Try to get fvm global version | ||
final cacheVersion = await CacheService.getGlobal(); | ||
|
||
return await execCmd(cmd, cacheVersion, execArgs); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,8 @@ class FvmConfig { | |
if (env.isEmpty) { | ||
return null; | ||
} | ||
|
||
return env; | ||
} | ||
|
||
/// Check if config file exists | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters