@@ -4,6 +4,7 @@ const $path = require("path");
44const $child = require ( "child_process" ) ;
55const $toml = require ( "toml" ) ;
66const $rimraf = require ( "rimraf" ) ;
7+ const $os = require ( "os" ) ;
78const { createFilter } = require ( "rollup-pluginutils" ) ;
89
910
@@ -128,6 +129,21 @@ async function get_target_dir(dir) {
128129 //return JSON.parse(metadata).target_directory;
129130}
130131
132+ function wasm_pack_path ( options ) {
133+ if ( options . wasmPackPath !== undefined ) {
134+ if ( typeof ( options . wasmPackPath ) === "string" ) {
135+ // Quick hack to allow use of "~" for home directory?
136+ return ( options . wasmPackPath . startsWith ( "~" ) ? options . wasmPackPath . replace ( "~" , $os . homedir ( ) ) : options . wasmPackPath ) ;
137+ } else {
138+ throw new Error ( "'wasmPackPath' must be a string" )
139+ }
140+ } else if ( process . platform === "win32" ) {
141+ // TODO pretty hacky, but needed to make it work on Windows
142+ return "wasm-pack.cmd"
143+ } else {
144+ return "wasm-pack"
145+ }
146+ }
131147
132148async function wasm_pack ( cx , state , dir , source , id , options ) {
133149 const target_dir = await get_target_dir ( dir ) ;
@@ -150,8 +166,7 @@ async function wasm_pack(cx, state, dir, source, id, options) {
150166 "--" ,
151167 ] . concat ( options . cargoArgs ) ;
152168
153- // TODO pretty hacky, but needed to make it work on Windows
154- const command = ( process . platform === "win32" ? "wasm-pack.cmd" : "wasm-pack" ) ;
169+ const command = wasm_pack_path ( options ) ;
155170
156171 try {
157172 // TODO what if it tries to build the same crate multiple times ?
0 commit comments