@@ -10,6 +10,8 @@ use JSON::Tiny;
10
10
my ($ PROGRAM_DIR ) = ~ ($ * PROGRAM_NAME ~~ /^ (.* \ /)/ ) // ' ./' ;
11
11
chdir $ PROGRAM_DIR ;
12
12
$ PROGRAM_DIR = cwd;
13
+ my $ COMPONENTS_DIR = " $ PROGRAM_DIR /components" ;
14
+
13
15
14
16
# = Show benchmark configuration
15
17
multi MAIN (' config' ) {
@@ -28,14 +30,11 @@ multi MAIN ('setup') {
28
30
my $ components = from-json(slurp ' components.json' );
29
31
30
32
say ' Cloning component repos ...' ;
31
- chdir ' components' ;
32
- my $ comp_dir = cwd;
33
-
34
33
for $ components . values -> $ component {
35
34
my $ name = $ component <name >;
36
35
say " ==> $ name" ;
37
36
38
- chdir $ comp_dir ;
37
+ chdir $ COMPONENTS_DIR ;
39
38
mkdir $ name unless $ name . IO . d ;
40
39
chdir $ name ;
41
40
@@ -50,19 +49,14 @@ multi MAIN ('setup') {
50
49
51
50
# = Fetch latest commits in each cloned component
52
51
multi MAIN (' fetch' ) {
53
- unless ' components' . IO . d {
54
- say " There is no 'components' tree, and thus there are no repos to fetch." ;
55
- say " Please run `$ * PROGRAM_NAME setup` instead." ;
56
- return ;
57
- }
52
+ needs-setup(' fetch' );
58
53
59
- chdir ' components' ;
60
- my $ comp_dir = cwd;
54
+ chdir $ COMPONENTS_DIR ;
61
55
62
56
for dir(' .' ). sort -> $ component-name {
63
57
say " ==> $ component-name" ;
64
- my $ bare = " $ component-name /$ component-name .git" ;
65
58
59
+ my $ bare = " $ component-name /$ component-name .git" ;
66
60
unless $ bare . IO . d {
67
61
say " No bare repository exists for component $ component-name ; can't fetch updates." ;
68
62
next ;
@@ -73,6 +67,14 @@ multi MAIN ('fetch') {
73
67
}
74
68
}
75
69
70
+ sub needs-setup ($ action ) {
71
+ unless $ COMPONENTS_DIR . IO . d {
72
+ say " There is no 'components' tree, and thus there are no repos to $ action ." ;
73
+ say " Please run `$ * PROGRAM_NAME setup`." ;
74
+ exit 1 ;
75
+ }
76
+ }
77
+
76
78
multi MAIN (' build' ) {
77
79
# %*ENV<GIT_DIR> = $bare;
78
80
# my $tag_list = open 'git tag', :p;
0 commit comments