File tree Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Expand file tree Collapse file tree 3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " next-css-linter" ,
3
- "version" : " 1.4.1 " ,
3
+ "version" : " 1.5.0 " ,
4
4
"description" : " Linter for NextJs CSS modules" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -14,14 +14,8 @@ pub struct Properties {
14
14
pub exclude : Vec < String > ,
15
15
}
16
16
17
- pub fn get_compiler_options ( ) -> Properties {
18
- let tsconfig_contents = fs:: read_to_string ( "tsconfig.json" )
19
- . expect ( "Could not load tsconfig. Is the provided directory is typescript project?" ) ;
17
+ pub fn get_compiler_options ( ) -> anyhow:: Result < Properties > {
18
+ let tsconfig_contents = fs:: read_to_string ( "tsconfig.json" ) ?;
20
19
21
- let v: Properties = match serde_json:: from_str ( & tsconfig_contents) {
22
- Ok ( res) => res,
23
- Err ( err) => panic ! ( "{}" , err) ,
24
- } ;
25
-
26
- v
20
+ Ok ( serde_json:: from_str ( & tsconfig_contents) ?)
27
21
}
Original file line number Diff line number Diff line change @@ -67,7 +67,13 @@ fn main() -> Result<()> {
67
67
) ;
68
68
process:: exit ( 1 ) ;
69
69
}
70
- let tsconfig = get_compiler_options ( ) ;
70
+ let tsconfig = get_compiler_options ( ) . unwrap_or_else ( |e| {
71
+ eprintln ! (
72
+ "\n {}Error{}: Could not load tsconfig.json. Is the provided directory is typescript project? ({})" ,
73
+ COLOR_RED , COLOR_RESET , e
74
+ ) ;
75
+ process:: exit ( 1 ) ;
76
+ } ) ;
71
77
72
78
let dir = list_files_in_directory ( Path :: new ( "." ) . to_path_buf ( ) , tsconfig. exclude ) ;
73
79
You can’t perform that action at this time.
0 commit comments