run method

  1. @override
FutureOr? run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
FutureOr? run() async {
  final platform = JSON(argResults?['platform']).stringValue;
  final buildType = JSON(argResults?['buildType']).stringValue;
  final root = JSON(argResults?['root']).stringValue;
  final assetPath = join(root, 'ProjectSettings', 'ProjectSettings.asset');
  if (platform == 'ios') {
    final contents = await File(assetPath).readAsLines();
    for (int i = 0; i < contents.length; i++) {
      var content = contents[i];
      if (content.contains('selectedPlatform:')) {
        contents[i] = 'selectedPlatform: ${buildType == 'debug' ? 3 : 2}';
      }
    }
    await File(assetPath).writeAsString(contents.join('\n'));
    if (buildType == 'debug') {
      final clrData = Directory(join(root, 'HybridCLRData'));
      if (await clrData.exists()) {
        await clrData.delete(recursive: true);
      }
    }
  }
}