@@ -64,6 +64,8 @@ macro_rules! create_config {
64
64
// if a license_template_path has been specified, successfully read, parsed and compiled
65
65
// into a regex, it will be stored here
66
66
pub license_template: Option <Regex >,
67
+ // The location from which to resolve relative dirs.
68
+ root_dir: Option <PathBuf >,
67
69
// For each config item, we store a bool indicating whether it has
68
70
// been accessed and the value, and a bool whether the option was
69
71
// manually initialised, or taken from the default,
@@ -166,6 +168,7 @@ macro_rules! create_config {
166
168
self . set_license_template( ) ;
167
169
self . set_ignore( dir) ;
168
170
self . set_merge_imports( ) ;
171
+ self . set_root_dir( dir) ;
169
172
self
170
173
}
171
174
@@ -390,7 +393,7 @@ macro_rules! create_config {
390
393
if self . was_set( ) . license_template_path( ) {
391
394
let lt_path = self . license_template_path( ) ;
392
395
if lt_path. len( ) > 0 {
393
- match license:: load_and_compile_template( self . get_ignore ( ) , & lt_path) {
396
+ match license:: load_and_compile_template( & self . root_dir , & lt_path) {
394
397
Ok ( re) => self . license_template = Some ( re) ,
395
398
Err ( msg) => eprintln!( "Warning for license template file {:?}: {}" ,
396
399
lt_path, msg) ,
@@ -405,6 +408,10 @@ macro_rules! create_config {
405
408
self . ignore. 2 . add_prefix( dir) ;
406
409
}
407
410
411
+ fn set_root_dir( & mut self , dir: & Path ) {
412
+ self . root_dir = Some ( dir. to_path_buf( ) ) ;
413
+ }
414
+
408
415
fn set_merge_imports( & mut self ) {
409
416
if self . was_set( ) . merge_imports( ) {
410
417
eprintln!(
@@ -438,6 +445,7 @@ macro_rules! create_config {
438
445
fn default ( ) -> Config {
439
446
Config {
440
447
license_template: None ,
448
+ root_dir: None ,
441
449
$(
442
450
$i: ( Cell :: new( false ) , false , $def, $stb) ,
443
451
) +
0 commit comments