Skip to content

Commit 7d6d730

Browse files
authored
Made nj-cli exit non-zero when cargo build fails. (#105)
1 parent 7b516e7 commit 7d6d730

File tree

4 files changed

+81
-9
lines changed

4 files changed

+81
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nj-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nj-cli"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
authors = ["fluvio.io"]
55
edition = "2018"
66
description = "build tool for node-bindgen"
@@ -12,4 +12,4 @@ log = "0.4.8"
1212
structopt = { version = "0.3.18", default-features = false }
1313
cargo_metadata = "0.11.3"
1414
toml = "0.5.6"
15-
serde = { version = "1.0.114", features = ["derive"] }
15+
serde = { version = "1.0.114", features = ["derive"] }

nj-cli/src/main.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn init(opt: InitOpt) {
8282
.stdout(Stdio::inherit())
8383
.spawn()
8484
.expect("Failed to execute command");
85-
85+
8686
build_command.wait()
8787
.expect("failed to wait on child");
8888

@@ -97,7 +97,7 @@ fn init(opt: InitOpt) {
9797
.args(&["fmt", &manifest_path])
9898
.spawn()
9999
.expect("Failed to execute command");
100-
100+
101101
fmt.wait()
102102
.expect("Failed to execute command");
103103
};
@@ -119,9 +119,30 @@ fn build(opt: BuildOpt) {
119119
.spawn()
120120
.expect("Failed to execute command");
121121

122-
build_command.wait()
122+
let status = build_command.wait()
123123
.expect("failed to wait on child");
124-
124+
match status.code() {
125+
Some(code) if code != 0 => {
126+
std::process::exit(code);
127+
}
128+
None => {
129+
//https://doc.rust-lang.org/std/process/struct.ExitStatus.html#method.code
130+
#[cfg(unix)]
131+
{
132+
use std::os::unix::process::ExitStatusExt;
133+
if let Some(signal) = status.signal() {
134+
std::process::exit(signal);
135+
} else {
136+
std::process::exit(1);
137+
}
138+
}
139+
#[cfg(not(unix))]
140+
{
141+
std::process::exit(1);
142+
}
143+
}
144+
Some(_) => {}
145+
}
125146
let target = if opt.release {
126147
"release"
127148
} else {
@@ -132,7 +153,7 @@ fn build(opt: BuildOpt) {
132153

133154
}
134155

135-
/// copy library to target directory
156+
/// copy library to target directory
136157
fn copy_lib(out: String,target_type: &str) {
137158

138159
let manifest_path = manifest_path();
@@ -198,7 +219,7 @@ fn lib_path(target: &Path,build_type: &str,target_name: &str) -> PathBuf {
198219
}else{
199220
panic!("Unsupported operating system.");
200221
}.replace("-","_");
201-
222+
202223
target.join(target).join(build_type).join(file_name)
203224
}
204225

notes.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
* [ ] napi_create_arraybuffer - NOT HERE
2+
* [ ] napi_create_buffer
3+
* [ ] napi_create_buffer_copy
4+
* [ ] napi_create_date
5+
* [ ] napi_create_external
6+
* [ ] napi_create_external_arraybuffer
7+
* [ ] napi_create_external_buffer
8+
* [ ] napi_create_symbol
9+
* [ ] napi_create_typedarray
10+
* [ ] napi_create_dataview
11+
* [ ] napi_create_uint32
12+
* [ ] napi_create_bigint_int64
13+
* [ ] napi_create_bigint_uint64
14+
* [ ] napi_create_bigint_words
15+
* [ ] napi_create_string_latin1
16+
* [ ] napi_get_array_length
17+
* [ ] napi_get_arraybuffer_info
18+
* [ ] napi_get_buffer_info
19+
* [ ] napi_get_prototype
20+
* [ ] napi_get_typedarray_info
21+
* [ ] napi_get_dataview_info
22+
* [ ] napi_get_value_bool
23+
* [ ] napi_get_value_double
24+
* [ ] napi_get_value_bigint_int64
25+
* [ ] napi_get_value_bigint_uint64
26+
* [ ] napi_get_value_bigint_words
27+
* [ ] napi_get_value_external
28+
* [ ] napi_get_value_int32
29+
* [ ] napi_get_value_int64
30+
* [ ] napi_get_value_string_utf8
31+
* [ ] napi_get_value_uint32
32+
* [ ] napi_get_null
33+
* [ ] napi_coerce_to_bool
34+
* [ ] napi_coerce_to_number
35+
* [ ] napi_coerce_to_string
36+
* [ ] napi_instanceof
37+
* [ ] napi_is_dataview
38+
* [ ] napi_strict_equals
39+
* [ ] napi_detach_arraybuffer
40+
* [ ] napi_is_detached_arraybuffer
41+
* [ ] napi_get_property_names
42+
* [ ] napi_get_all_property_names
43+
* [ ] napi_delete_property
44+
* [ ] napi_set_named_property
45+
* [ ] napi_get_named_property
46+
* [ ] napi_has_named_property
47+
* [ ] napi_has_element
48+
* [ ] napi_delete_element
49+
* [ ] napi_create_function
50+
* [ ] napi_get_version
51+
* [ ] napi_get_uv_event_loop

0 commit comments

Comments
 (0)