Skip to content

Commit cd9a16e

Browse files
committed
downstream rescript changes
1 parent 5142449 commit cd9a16e

File tree

17 files changed

+79
-45
lines changed

17 files changed

+79
-45
lines changed

src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn get_compiler_args(
7272
rescript_version
7373
} else {
7474
let bsc_path = match bsc_path {
75-
Some(bsc_path) => bsc_path,
75+
Some(bsc_path) => helpers::get_abs_path(&bsc_path),
7676
None => helpers::get_bsc(&package_root, workspace_root.to_owned()),
7777
};
7878
helpers::get_rescript_version(&bsc_path)

src/build/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub fn clean(path: &str, show_progress: bool, bsc_path: Option<String>) -> Resul
351351
)?;
352352
let root_config_name = packages::read_package_name(&project_root)?;
353353
let bsc_path = match bsc_path {
354-
Some(bsc_path) => bsc_path,
354+
Some(bsc_path) => helpers::get_abs_path(&bsc_path),
355355
None => helpers::get_bsc(&project_root, workspace_root.to_owned()),
356356
};
357357

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fn main() -> Result<()> {
149149
args.after_build,
150150
args.create_sourcedirs,
151151
args.dev,
152+
args.bsc_path,
152153
);
153154

154155
Ok(())

src/watcher.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ async fn async_watch(
5454
after_build: Option<String>,
5555
create_sourcedirs: bool,
5656
build_dev_deps: bool,
57+
bsc_path: Option<String>,
5758
) -> notify::Result<()> {
58-
let mut build_state = build::initialize_build(None, filter, show_progress, path, None, build_dev_deps)
59-
.expect("Can't initialize build");
59+
let mut build_state = build::initialize_build(
60+
None,
61+
filter,
62+
show_progress,
63+
path,
64+
None,
65+
build_dev_deps,
66+
bsc_path.clone(),
67+
)
68+
.expect("Can't initialize build");
6069
let mut needs_compile_type = CompileType::Incremental;
6170
// create a mutex to capture if ctrl-c was pressed
6271
let ctrlc_pressed = Arc::new(Mutex::new(false));
@@ -91,6 +100,20 @@ async fn async_watch(
91100
}
92101

93102
for event in events {
103+
// if there is a file named rewatch.lock in the events path, we can quit the watcher
104+
if let Some(_) = event.paths.iter().find(|path| path.ends_with("rewatch.lock")) {
105+
match event.kind {
106+
EventKind::Remove(_) => {
107+
if show_progress {
108+
println!("\nExiting... (lockfile removed)");
109+
}
110+
clean::cleanup_after_build(&build_state);
111+
return Ok(());
112+
}
113+
_ => (),
114+
}
115+
}
116+
94117
let paths = event
95118
.paths
96119
.iter()
@@ -214,9 +237,8 @@ async fn async_watch(
214237
}
215238
CompileType::Full => {
216239
let timing_total = Instant::now();
217-
build_state =
218-
build::initialize_build(None, filter, show_progress, path, None, build_dev_deps)
219-
.expect("Can't initialize build");
240+
build_state = build::initialize_build(None, filter, show_progress, path, None)
241+
.expect("Can't initialize build");
220242
let _ = build::incremental_build(
221243
&mut build_state,
222244
None,
@@ -260,6 +282,7 @@ pub fn start(
260282
after_build: Option<String>,
261283
create_sourcedirs: bool,
262284
build_dev_deps: bool,
285+
bsc_path: Option<String>,
263286
) {
264287
futures::executor::block_on(async {
265288
let queue = Arc::new(FifoQueue::<Result<Event, Error>>::new());
@@ -280,6 +303,7 @@ pub fn start(
280303
after_build,
281304
create_sourcedirs,
282305
build_dev_deps,
306+
bsc_path,
283307
)
284308
.await
285309
{

testrepo/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"packages/with-dev-deps"
1212
]
1313
},
14+
"dependencies": {
15+
"rescript": "11.1.4"
16+
},
1417
"scripts": {
1518
"build": "../target/release/rewatch build .",
1619
"build:rescript": "rescript build -with-deps",

testrepo/packages/dep01/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"author": "",
1313
"license": "MIT",
1414
"dependencies": {
15-
"@testrepo/dep02": "*",
16-
"rescript": "*"
15+
"@testrepo/dep02": "*"
1716
}
1817
}

testrepo/packages/dep02/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@
1010
"rescript"
1111
],
1212
"author": "",
13-
"license": "MIT",
14-
"dependencies": {
15-
"rescript": "*"
16-
}
13+
"license": "MIT"
1714
}

testrepo/packages/main/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"author": "",
1313
"license": "MIT",
1414
"dependencies": {
15-
"@testrepo/dep01": "*",
16-
"rescript": "*"
15+
"@testrepo/dep01": "*"
1716
}
1817
}

testrepo/packages/new-namespace/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@
55
"rescript"
66
],
77
"author": "",
8-
"license": "MIT",
9-
"dependencies": {
10-
"rescript": "*"
11-
}
8+
"license": "MIT"
129
}

testrepo/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
resolved "https://registry.yarnpkg.com/@rescript/core/-/core-1.6.1.tgz#159670c94d64a2b8236f46be2bf09a007b1ece08"
88
integrity sha512-vyb5k90ck+65Fgui+5vCja/mUfzKaK3kOPT4Z6aAJdHLH1eljEi1zKhXroCiCtpNLSWp8k4ulh1bdB5WS0hvqA==
99

10-
rescript@*:
10+
rescript@*, [email protected]:
1111
version "11.1.4"
1212
resolved "https://registry.yarnpkg.com/rescript/-/rescript-11.1.4.tgz#9a42ebc4fc5363707e39cef5b3188160b63bee42"
1313
integrity sha512-0bGU0bocihjSC6MsE3TMjHjY0EUpchyrREquLS8VsZ3ohSMD+VHUEwimEfB3kpBI1vYkw3UFZ3WD8R28guz/Vw==

0 commit comments

Comments
 (0)