11
11
# ' styling whether or not it was actually changed (or would be changed when
12
12
# ' `dry` is not "off").
13
13
# ' @keywords internal
14
+ # ' @importFrom rlang local_options
14
15
transform_files <- function (files , transformers , include_roxygen_examples , base_indention , dry ) {
15
16
transformer <- make_transformer(transformers , include_roxygen_examples , base_indention )
16
17
max_char <- min(max(nchar(files ), 0 ), getOption(" width" ))
@@ -19,9 +20,23 @@ transform_files <- function(files, transformers, include_roxygen_examples, base_
19
20
cat(" Styling " , len_files , " files:\n " )
20
21
}
21
22
22
- changed <- map_lgl(files , transform_file ,
23
- fun = transformer , max_char_path = max_char , dry = dry
24
- )
23
+ if (rlang :: is_installed(" furrr" )) {
24
+ if (inherits(future :: plan(), " uniprocess" )) {
25
+ local_options(future.supportsMulticore.unstable = " quiet" )
26
+ oplan <- future :: plan(" multiprocess" )
27
+ on.exit(future :: plan(oplan ), add = TRUE )
28
+ }
29
+
30
+ changed <- furrr :: future_map_lgl(files , transform_file ,
31
+ fun = transformer , max_char_path = max_char , dry = dry ,
32
+ .progress = TRUE
33
+ )
34
+ } else {
35
+ changed <- map_lgl(files , transform_file ,
36
+ fun = transformer , max_char_path = max_char , dry = dry
37
+ )
38
+ }
39
+
25
40
communicate_summary(changed , max_char )
26
41
communicate_warning(changed , transformers )
27
42
new_tibble(list (file = files , changed = changed ), nrow = len_files )
0 commit comments