Skip to content

Commit

Permalink
[ Fix ] fixed the issue related to filename of config files
Browse files Browse the repository at this point in the history
  • Loading branch information
anasfik committed Oct 23, 2023
1 parent 2f47b2f commit 5a219f6
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 29 deletions.
3 changes: 0 additions & 3 deletions example/locales/ar.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/de.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/en.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/es.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/fr.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/ge.json

This file was deleted.

3 changes: 0 additions & 3 deletions example/locales/zh.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class ConfigValidateCommand extends Command<int> {
ConfigFile _controllerFromFile({
required List<FileSystemEntity> configFiles,
}) {
print(configFiles.length);

if (configFiles.isEmpty) {
logger
..info(
Expand Down
11 changes: 6 additions & 5 deletions lib/src/etc/controllers/config_file.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';

import 'package:args/src/arg_results.dart';
import 'package:langsync/src/etc/extensions.dart';
import 'package:mason_logger/mason_logger.dart';
import 'package:meta/meta.dart';

Expand Down Expand Up @@ -29,7 +30,7 @@ abstract class ConfigFile {
static Iterable<FileSystemEntity> get configFilesInCurrentDir =>
Directory('.').listSync().where(
(file) {
final fileName = file.path.split('/').last;
final fileName = file.fileNameOnly;

return _controllers.containsKey(fileName);
},
Expand All @@ -39,9 +40,9 @@ abstract class ConfigFile {

File get configFileRef;

String get configFileExtension => configFileRef.path.split('.').last;
// String get configFileExtension => configFileRef.path.split('.').last;

String get configFileName => configFileRef.path.split('/').last;
String get configFileName => configFileRef.fileNameOnly;

Future<Map<dynamic, dynamic>> parsed();

Expand Down Expand Up @@ -154,8 +155,8 @@ abstract class ConfigFile {

Future<void> writeNewConfig(Map<String, dynamic> config);

static ConfigFile controllerFromFile(FileSystemEntity first) {
final fileName = first.path.split('/').last;
static ConfigFile controllerFromFile(FileSystemEntity file) {
final fileName = file.fileNameOnly;

return _controllers[fileName]!;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/src/etc/extensions.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';

import 'package:langsync/src/etc/models/config.dart';
import 'package:langsync/src/etc/utils.dart';
import 'package:mason_logger/mason_logger.dart';
import 'package:path/path.dart';

final randomframesToUse = utils.randomLoadingFrames();

Expand Down Expand Up @@ -108,3 +110,7 @@ extension DateExt on DateTime {
return '${day.toString().padLeft(2, '0')}/${month.toString().padLeft(2, '0')}/${year.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}';
}
}

extension FileSystemEntityExt on FileSystemEntity {
String get fileNameOnly => basename(path);
}
3 changes: 2 additions & 1 deletion lib/src/etc/networking/client_boilerplate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:langsync/src/etc/extensions.dart';
import 'package:langsync/src/etc/utils.dart';

class NetClientBoilerPlate {
Expand Down Expand Up @@ -53,7 +54,7 @@ class NetClientBoilerPlate {
final multipartFile = http.MultipartFile.fromBytes(
key,
value.readAsBytesSync(),
filename: value.path.split('/').last,
filename: value.fileNameOnly,
);

request.files.add(multipartFile);
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies:
http: ^1.1.0
mason_logger: ^0.2.4
meta: ^1.11.0
path: ^1.8.3
pub_updater: ^0.3.0
yaml: ^3.1.2

Expand Down

0 comments on commit 5a219f6

Please sign in to comment.