Skip to content

Commit

Permalink
add error when path does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Dec 12, 2023
1 parent ce59009 commit 0c5cb03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Then run command with no args to see the help:
extism-js
error: The following required arguments were not provided:
<input-js>
-i <interface-file>
USAGE:
extism-js <input-js> -i <interface-file> -o <output>
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Options {
#[structopt(parse(from_os_str))]
pub input_js: PathBuf,

#[structopt(short = "i", parse(from_os_str))]
#[structopt(short = "i", parse(from_os_str), default_value = "index.d.ts")]
pub interface_file: PathBuf,

#[structopt(short = "o", parse(from_os_str), default_value = "index.wasm")]
Expand Down
10 changes: 10 additions & 0 deletions crates/cli/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ fn parse_module_decl(tsmod: &Box<TsModuleDecl>) -> Result<Interface> {
.function
.params
.iter()
.map(|p| {
dbg!(p);
p
})
.map(|p| Param {
name: String::from("c"),
ptype: String::from("I32"),
Expand Down Expand Up @@ -187,6 +191,12 @@ fn generate_export_wasm_shim(exports: &Interface, export_path: &PathBuf) -> Resu

pub fn create_shims(interface_path: &PathBuf, export_path: &PathBuf) -> Result<()> {
let cm: Lrc<SourceMap> = Default::default();
if !interface_path.exists() {
bail!(
"Could not find interface file {}. Set to a valid d.ts file with the -i flag",
&interface_path.to_str().unwrap()
);
}
let fm = cm.load_file(&interface_path)?;
let lexer = Lexer::new(
Syntax::Typescript(Default::default()),
Expand Down

0 comments on commit 0c5cb03

Please sign in to comment.