@@ -2,27 +2,34 @@ import 'dart:io';
22
33import 'package:path/path.dart' as p;
44
5+ /// key - step filename, value - path for import (ex: {'i_have_a_step.dart': 'step/common'})
56Map <String , String > getExistingStepSubfolders (
6- String featureDir, String stepFolderName) {
7+ String featureDir,
8+ String stepFolderName,
9+ ) {
710 final stepFolder = p.join (featureDir, stepFolderName);
811 final steps = Directory (stepFolder);
912 if (! steps.existsSync ()) {
1013 return {};
1114 }
1215 return steps.listSync (recursive: true ).asMap ().map (
13- (key, value) => MapEntry <String , String >(
14- p.basename (value.path),
15- _getStepFolder (
16- value.uri.pathSegments,
16+ (_, step) => MapEntry <String , String >(
17+ p.basename (step.path),
18+ _getStepSubfolders (
19+ steps.uri.pathSegments.length,
20+ step.uri.pathSegments,
1721 stepFolderName,
1822 ),
1923 ),
2024 );
2125}
2226
23- String _getStepFolder (List <String > pathSegments, String stepFolderName) {
24- final stepFolderIndex = pathSegments.indexOf (stepFolderName);
25- final stepFolder =
26- pathSegments.getRange (stepFolderIndex, pathSegments.length - 1 );
27- return p.joinAll (stepFolder);
27+ String _getStepSubfolders (
28+ int stepFolderPathSegmentsLength,
29+ List <String > currentStepPath,
30+ String stepFolderName,
31+ ) {
32+ final pathDiff = currentStepPath.getRange (
33+ stepFolderPathSegmentsLength - 1 , currentStepPath.length - 1 );
34+ return p.joinAll ([stepFolderName, ...pathDiff]);
2835}
0 commit comments