summaryrefslogtreecommitdiff
path: root/cli/compiler.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2019-04-29 15:58:31 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-04-29 07:58:31 -0700
commit1a0f53a807abad0e9ebfcf437f3dade6b01d7f84 (patch)
tree013eb8d15383a22a4e2c4c5502ba37035b397903 /cli/compiler.rs
parent73be183864d0983821e683198d9a6ea9008f070a (diff)
Add support for custom tsconfig.json (#2089)
Use `--config`
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);
+ }
}