-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
136 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
build/ | ||
*.g.dart | ||
|
||
.catalyst_builder_cache/ | ||
.cache/ |
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,42 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart' as p; | ||
import 'package:yaml/yaml.dart'; | ||
|
||
import '../constants.dart' as c; | ||
|
||
/// Represents the config file for advanced configuration | ||
class Config { | ||
/// The directory for the builder cache. | ||
/// This could be an relative or absolute path. | ||
String cacheDir; | ||
|
||
/// Creates the config object | ||
Config({ | ||
this.cacheDir = c.cacheDir, | ||
}); | ||
|
||
/// Load the configuration from [configFileName] or fallback to the default. | ||
factory Config.load() { | ||
var configFile = File(p.join(p.current, 'pubspec.yaml')); | ||
|
||
if (configFile.existsSync()) { | ||
var content = loadYaml(configFile.readAsStringSync()) as YamlMap; | ||
if (content.containsKey('catalyst_builder')) { | ||
var yamlJson = jsonEncode(content['catalyst_builder']); | ||
var configFromYaml = jsonDecode(yamlJson) as Map; | ||
return Config.fromJson(configFromYaml.cast()); | ||
} | ||
} | ||
|
||
return Config(); | ||
} | ||
|
||
/// Creates a new instance from the result of [toJson]. | ||
factory Config.fromJson(Map<String, dynamic> json) { | ||
return Config( | ||
cacheDir: json['cacheDir']?.toString() ?? c.cacheDir, | ||
); | ||
} | ||
} |
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
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