mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-05-04 18:12:16 +00:00
Expose typescript option in wasm2es6js
This commit is contained in:
parent
89c8621426
commit
1487288050
@ -4,13 +4,11 @@ extern crate docopt;
|
|||||||
extern crate parity_wasm;
|
extern crate parity_wasm;
|
||||||
extern crate wasm_bindgen_cli_support;
|
extern crate wasm_bindgen_cli_support;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Write, Read};
|
use std::io::{Write, Read};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use docopt::Docopt;
|
use docopt::Docopt;
|
||||||
use parity_wasm::elements::*;
|
|
||||||
|
|
||||||
const USAGE: &'static str = "
|
const USAGE: &'static str = "
|
||||||
Converts a wasm file to an ES6 JS module
|
Converts a wasm file to an ES6 JS module
|
||||||
@ -22,12 +20,14 @@ Usage:
|
|||||||
Options:
|
Options:
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
-o --output FILE File to place output in
|
-o --output FILE File to place output in
|
||||||
|
--output-ts FILE File to place a typescript definition of the module to
|
||||||
--base64 Inline the wasm module using base64 encoding
|
--base64 Inline the wasm module using base64 encoding
|
||||||
";
|
";
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Args {
|
struct Args {
|
||||||
flag_output: Option<PathBuf>,
|
flag_output: Option<PathBuf>,
|
||||||
|
flag_output_ts: Option<PathBuf>,
|
||||||
flag_base64: bool,
|
flag_base64: bool,
|
||||||
arg_input: PathBuf,
|
arg_input: PathBuf,
|
||||||
}
|
}
|
||||||
@ -49,6 +49,12 @@ fn main() {
|
|||||||
.base64(args.flag_base64)
|
.base64(args.flag_base64)
|
||||||
.generate(&wasm)
|
.generate(&wasm)
|
||||||
.expect("failed to parse wasm");
|
.expect("failed to parse wasm");
|
||||||
|
|
||||||
|
if let Some(ref p) = args.flag_output_ts {
|
||||||
|
File::create(p).expect("failed to create output")
|
||||||
|
.write_all(object.typescript().as_bytes()).expect("failed to write output");
|
||||||
|
}
|
||||||
|
|
||||||
let js = object.js();
|
let js = object.js();
|
||||||
|
|
||||||
match args.flag_output {
|
match args.flag_output {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user