summaryrefslogtreecommitdiff
path: root/cli/compiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/compiler.rs')
-rw-r--r--cli/compiler.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/compiler.rs b/cli/compiler.rs
index d327835d3..522002b0b 100644
--- a/cli/compiler.rs
+++ b/cli/compiler.rs
@@ -158,6 +158,23 @@ fn req(specifier: &str, referrer: &str, cmd_id: u32) -> Buf {
.into_boxed_bytes()
}
+/// Returns an optional tuple which represents the state of the compiler
+/// configuration where the first is canonical name for the configuration file
+/// and a vector of the bytes of the contents of the configuration file.
+pub fn get_compiler_config(
+ parent_state: &ThreadSafeState,
+ _compiler_type: &str,
+) -> Option<(String, Vec<u8>)> {
+ // The compiler type is being passed to make it easier to implement custom
+ // compilers in the future.
+ match (&parent_state.config_path, &parent_state.config) {
+ (Some(config_path), Some(config)) => {
+ Some((config_path.to_string(), config.to_vec()))
+ }
+ _ => None,
+ }
+}
+
pub fn compile_async(
parent_state: ThreadSafeState,
specifier: &str,
@@ -306,4 +323,12 @@ mod tests {
assert_eq!(parse_cmd_id(res_json), cmd_id);
}
+
+ #[test]
+ fn test_get_compiler_config_no_flag() {
+ let compiler_type = "typescript";
+ let state = ThreadSafeState::mock();
+ let out = get_compiler_config(&state, compiler_type);
+ assert_eq!(out, None);
+ }
}