Skip to content

Commit

Permalink
fixes #189 - export feature take proper path
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Dec 24, 2023
1 parent 2391000 commit 6b56127
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/export/ts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::{collections::BTreeMap, path::Path};

use crate::{
ts::{self, ExportConfig, ExportError},
Expand All @@ -8,12 +8,12 @@ use crate::{
use super::get_types;

/// Exports all types in the [`TYPES`](static@crate::export::TYPES) map to the provided TypeScript file.
pub fn ts(path: &str) -> Result<(), ExportError> {
pub fn ts<P: AsRef<Path>>(path: P) -> Result<(), ExportError> {
ts_with_cfg(path, &ExportConfig::default())
}

/// Exports all types in the [`TYPES`](static@crate::export::TYPES) map to the provided TypeScript file but allow you to provide a configuration for the exporter.
pub fn ts_with_cfg(path: &str, conf: &ExportConfig) -> Result<(), ExportError> {
pub fn ts_with_cfg<P: AsRef<Path>>(path: P, conf: &ExportConfig) -> Result<(), ExportError> {
let mut out = "// This file has been generated by Specta. DO NOT EDIT.\n\n".to_string();

// We sort by name to detect duplicate types BUT also to ensure the output is deterministic. The SID can change between builds so is not suitable for this.
Expand Down

0 comments on commit 6b56127

Please sign in to comment.