pub fn load(maybe_config_path: Option<String>) -> Result<Self, AnyError> {
    if maybe_config_path.is_none() {
      return Ok(Self {
        path: Some(PathBuf::new()),
        options: json!({}),
        maybe_ignored_options: None,
        hash: "".to_string(),
        compile_js: false,
      });
    }

    let raw_config_path = maybe_config_path.unwrap();
    debug!("Compiler config file: {}", raw_config_path);
    let cwd = std::env::current_dir().unwrap();
    let config_file = cwd.join(raw_config_path);

    // Convert the PathBuf to a canonicalized string.  This is needed by the
    // compiler to properly deal with the configuration.
    let config_path = config_file.canonicalize().map_err(|_| {
      io::Error::new(
        io::ErrorKind::InvalidInput,
        format!(
          "Could not find the config file: {}",
          config_file.to_string_lossy()
        ),
      )
    })?;

    // Load the contents of the configuration file
    debug!("Attempt to load config: {}", config_path.to_str().unwrap());
    let config_bytes = fs::read(&config_file)?;
    let config_hash = crate::checksum::gen(&[&config_bytes]);
    let config_str = String::from_utf8(config_bytes)?;

    let (options, maybe_ignored_options) = if config_str.is_empty() {
      (json!({}), None)
    } else {
      tsc_config::parse_config(&config_str)?
    };

    // If `checkJs` is set to true in `compilerOptions` then we're gonna be compiling
    // JavaScript files as well
    let compile_js = options["checkJs"].as_bool().unwrap_or(false);

    Ok(Self {
      path: Some(config_path),
      options,
      maybe_ignored_options,
      hash: config_hash,
      compile_js,
    })
  }
/// Take the passed flag and resolve the file name relative to the cwd.
Take the passed flag and resolve the file name relative to the cwd.
Take the passed flag and resolve the file name relative to the cwd .
pub fn load(maybe_config_path: Option<String>) -> Result<Self, AnyError> {
    if maybe_config_path.is_none() {
      return Ok(Self {
        path: Some(PathBuf::new()),
        options: json!({}),
        maybe_ignored_options: None,
        hash: "".to_string(),
        compile_js: false,
      });
    }
    let raw_config_path = maybe_config_path.unwrap();
    debug!("Compiler config file: {}", raw_config_path);
    let cwd = std::env::current_dir().unwrap();
    let config_file = cwd.join(raw_config_path);
    // Convert the PathBuf to a canonicalized string.  This is needed by the
    // compiler to properly deal with the configuration.
    let config_path = config_file.canonicalize().map_err(|_| {
      io::Error::new(
        io::ErrorKind::InvalidInput,
        format!(
          "Could not find the config file: {}",
          config_file.to_string_lossy()
        ),
      )
    })?;
    // Load the contents of the configuration file
    debug!("Attempt to load config: {}", config_path.to_str().unwrap());
    let config_bytes = fs::read(&config_file)?;
    let config_hash = crate::checksum::gen(&[&config_bytes]);
    let config_str = String::from_utf8(config_bytes)?;
    let (options, maybe_ignored_options) = if config_str.is_empty() {
      (json!({}), None)
    } else {
      tsc_config::parse_config(&config_str)?
    };
    // If `checkJs` is set to true in `compilerOptions` then we're gonna be compiling
    // JavaScript files as well
    let compile_js = options["checkJs"].as_bool().unwrap_or(false);
    Ok(Self {
      path: Some(config_path),
      options,
      maybe_ignored_options,
      hash: config_hash,
      compile_js,
    })
  }
pub fn load ( maybe_config_path : Option < String > ) -> Result < Self , AnyError > { if maybe_config_path . is_none ( ) { return Ok ( Self { path : Some ( PathBuf :: new ( ) ) , options : json ! ( { } ) , maybe_ignored_options : None , hash : " " . to_string ( ) , compile_js : false , } ) ; } let raw_config_path = maybe_config_path . unwrap ( ) ; debug ! ( " " raw_config_path ) ; let cwd = std :: env :: current_dir ( ) . unwrap ( ) ; let config_file = cwd . join ( raw_config_path ) ; // Convert the PathBuf to a canonicalized string.  This is needed by the // compiler to properly deal with the configuration. let config_path = config_file . canonicalize ( ) . map_err ( | _ | { io :: Error :: new ( io :: ErrorKind :: InvalidInput , format ! ( " " config_file to_string_lossy ( ) ) , ) } ) ? ; // Load the contents of the configuration file debug ! ( " " config_path to_str ( ) unwrap ( ) ) ; let config_bytes = fs :: read ( & config_file ) ? ; let config_hash = crate :: checksum :: gen ( & [ & config_bytes ] ) ; let config_str = String :: from_utf8 ( config_bytes ) ? ; let ( options , maybe_ignored_options ) = if config_str . is_empty ( ) { ( json ! ( { } ) , None ) } else { tsc_config :: parse_config ( & config_str ) ? } ; // If `checkJs` is set to true in `compilerOptions` then we're gonna be compiling // JavaScript files as well let compile_js = options [ " " ] . as_bool ( ) . unwrap_or ( false ) ; Ok ( Self { path : Some ( config_path ) , options , maybe_ignored_options , hash : config_hash , compile_js , } ) }
Take the passed flag and resolve the file name relative to the cwd.
Take the passed flag and resolve the file name relative to the cwd .
maybe_config_path
Option<String>
maybe_config_path
Option<String>