read static method

List<ReplaceDto> read(
  1. String group,
  2. String path,
  3. String prefixNameReplaceFile
)

Implementation

static List<ReplaceDto> read(
  String group,
  String path,
  String prefixNameReplaceFile,
) {
  final file = '${prefixNameReplaceFile}_replace_trigger.json';
  var root = '.ft_cli';

  path = normalize(ReservedWords.removeWordsInFile(
    fileString: '$group/$path',
  ));

  var existFile = File('$root/$path/$file').existsSync();

  if (!existFile) {
    DirectoryUtils.create(root + '/' + path);

    File('$root/$path/$file').writeAsStringSync(
      json.encode(
        [
          ReplaceDto('', '', '').toJson(),
        ],
      ),
    );
  }

  return (json.decode(File('$root/$path/$file').readAsStringSync()) as List)
      .map((e) => ReplaceDto.fromJson(e))
      .toList();
}