File tree Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Original file line number Diff line number Diff line change 1
- use std:: { ffi:: OsString , ops:: Deref } ;
1
+ use std:: {
2
+ ffi:: OsString ,
3
+ ops:: Deref ,
4
+ path:: { Path , PathBuf } ,
5
+ } ;
2
6
3
7
use clap:: { Args , Parser , Subcommand } ;
4
8
use clap_verbosity_flag:: InfoLevel ;
@@ -45,7 +49,7 @@ pub struct Cli {
45
49
pub struct FolderArg {
46
50
/// The relative path to where the main rescript.json resides. IE - the root of your project.
47
51
#[ arg( default_value = "." ) ]
48
- pub folder : String ,
52
+ pub folder : PathBuf ,
49
53
}
50
54
51
55
#[ derive( Args , Debug , Clone ) ]
@@ -219,7 +223,7 @@ pub enum Command {
219
223
}
220
224
221
225
impl Deref for FolderArg {
222
- type Target = str ;
226
+ type Target = Path ;
223
227
224
228
fn deref ( & self ) -> & Self :: Target {
225
229
& self . folder
Original file line number Diff line number Diff line change @@ -59,8 +59,8 @@ fn create(lockfile_location: &Path, pid: u32) -> Lock {
59
59
. unwrap_or_else ( |e| Lock :: Error ( Error :: WritingLockfile ( e) ) )
60
60
}
61
61
62
- pub fn get ( folder : & str ) -> Lock {
63
- let ___location = Path :: new ( folder) . join ( "lib" ) . join ( LOCKFILE ) ;
62
+ pub fn get ( folder : & Path ) -> Lock {
63
+ let ___location = folder. join ( "lib" ) . join ( LOCKFILE ) ;
64
64
let pid = process:: id ( ) ;
65
65
66
66
match fs:: read_to_string ( & ___location) {
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ fn main() -> Result<()> {
39
39
40
40
match build:: build (
41
41
& build_args. filter ,
42
- Path :: new ( & build_args. folder as & str ) ,
42
+ & build_args. folder ,
43
43
show_progress,
44
44
build_args. no_timing ,
45
45
* build_args. create_sourcedirs ,
@@ -80,12 +80,7 @@ fn main() -> Result<()> {
80
80
} => {
81
81
let _lock = get_lock ( & folder) ;
82
82
83
- build:: clean:: clean (
84
- Path :: new ( & folder as & str ) ,
85
- show_progress,
86
- * snapshot_output,
87
- dev. dev ,
88
- )
83
+ build:: clean:: clean ( & folder, show_progress, * snapshot_output, dev. dev )
89
84
}
90
85
cli:: Command :: Legacy { legacy_args } => {
91
86
let code = build:: pass_through_legacy ( legacy_args) ;
@@ -100,7 +95,7 @@ fn main() -> Result<()> {
100
95
}
101
96
}
102
97
103
- fn get_lock ( folder : & str ) -> lock:: Lock {
98
+ fn get_lock ( folder : & Path ) -> lock:: Lock {
104
99
match lock:: get ( folder) {
105
100
lock:: Lock :: Error ( error) => {
106
101
println ! ( "Could not start ReScript build: {error}" ) ;
Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ async fn async_watch(
311
311
pub fn start (
312
312
filter : & Option < regex:: Regex > ,
313
313
show_progress : bool ,
314
- folder : & str ,
314
+ folder : & Path ,
315
315
after_build : Option < String > ,
316
316
create_sourcedirs : bool ,
317
317
build_dev_deps : bool ,
@@ -325,17 +325,15 @@ pub fn start(
325
325
let mut watcher = RecommendedWatcher :: new ( move |res| producer. push ( res) , Config :: default ( ) )
326
326
. expect ( "Could not create watcher" ) ;
327
327
328
- log:: debug!( "watching {folder}" ) ;
328
+ log:: debug!( "watching {}" , folder . display ( ) ) ;
329
329
330
330
watcher
331
331
. watch ( folder. as_ref ( ) , RecursiveMode :: Recursive )
332
332
. expect ( "Could not start watcher" ) ;
333
333
334
- let path = Path :: new ( folder) ;
335
-
336
334
if let Err ( e) = async_watch ( AsyncWatchArgs {
337
335
q : consumer,
338
- path,
336
+ path : folder ,
339
337
show_progress,
340
338
filter,
341
339
after_build,
You can’t perform that action at this time.
0 commit comments