@@ -3,6 +3,7 @@ use std::collections::HashSet;
3
3
use std:: fs;
4
4
use std:: path:: PathBuf ;
5
5
use utils:: { self , fixture} ;
6
+ use wasm_pack:: command:: build:: Target ;
6
7
use wasm_pack:: { self , license, manifest} ;
7
8
8
9
#[ test]
@@ -66,7 +67,7 @@ fn it_creates_a_package_json_default_path() {
66
67
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
67
68
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
68
69
assert ! ( crate_data
69
- . write_package_json( & out_dir, & None , false , "" , & step)
70
+ . write_package_json( & out_dir, & None , false , & Target :: Bundler , & step)
70
71
. is_ok( ) ) ;
71
72
let package_json_path = & fixture. path . join ( "pkg" ) . join ( "package.json" ) ;
72
73
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -102,7 +103,7 @@ fn it_creates_a_package_json_provided_path() {
102
103
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
103
104
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
104
105
assert ! ( crate_data
105
- . write_package_json( & out_dir, & None , false , "" , & step)
106
+ . write_package_json( & out_dir, & None , false , & Target :: Bundler , & step)
106
107
. is_ok( ) ) ;
107
108
let package_json_path = & fixture. path . join ( "pkg" ) . join ( "package.json" ) ;
108
109
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -131,7 +132,13 @@ fn it_creates_a_package_json_provided_path_with_scope() {
131
132
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
132
133
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
133
134
assert ! ( crate_data
134
- . write_package_json( & out_dir, & Some ( "test" . to_string( ) ) , false , "" , & step)
135
+ . write_package_json(
136
+ & out_dir,
137
+ & Some ( "test" . to_string( ) ) ,
138
+ false ,
139
+ & Target :: Bundler ,
140
+ & step
141
+ )
135
142
. is_ok( ) ) ;
136
143
let package_json_path = & fixture. path . join ( "pkg" ) . join ( "package.json" ) ;
137
144
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -160,7 +167,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() {
160
167
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
161
168
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
162
169
assert ! ( crate_data
163
- . write_package_json( & out_dir, & None , false , "nodejs" , & step)
170
+ . write_package_json( & out_dir, & None , false , & Target :: Nodejs , & step)
164
171
. is_ok( ) ) ;
165
172
let package_json_path = & out_dir. join ( "package.json" ) ;
166
173
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -196,7 +203,7 @@ fn it_creates_a_pkg_json_with_correct_files_on_nomodules() {
196
203
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
197
204
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
198
205
assert ! ( crate_data
199
- . write_package_json( & out_dir, & None , false , "no-modules" , & step)
206
+ . write_package_json( & out_dir, & None , false , & Target :: NoModules , & step)
200
207
. is_ok( ) ) ;
201
208
let package_json_path = & out_dir. join ( "package.json" ) ;
202
209
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -231,7 +238,7 @@ fn it_creates_a_pkg_json_in_out_dir() {
231
238
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
232
239
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
233
240
assert ! ( crate_data
234
- . write_package_json( & out_dir, & None , false , "" , & step)
241
+ . write_package_json( & out_dir, & None , false , & Target :: Bundler , & step)
235
242
. is_ok( ) ) ;
236
243
237
244
let package_json_path = & fixture. path . join ( & out_dir) . join ( "package.json" ) ;
@@ -247,7 +254,7 @@ fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() {
247
254
let step = wasm_pack:: progressbar:: Step :: new ( 1 ) ;
248
255
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
249
256
assert ! ( crate_data
250
- . write_package_json( & out_dir, & None , true , "" , & step)
257
+ . write_package_json( & out_dir, & None , true , & Target :: Bundler , & step)
251
258
. is_ok( ) ) ;
252
259
let package_json_path = & out_dir. join ( "package.json" ) ;
253
260
fs:: metadata ( package_json_path) . unwrap ( ) ;
@@ -310,7 +317,7 @@ fn it_sets_homepage_field_if_available_in_cargo_toml() {
310
317
let step = wasm_pack:: progressbar:: Step :: new ( 2 ) ;
311
318
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
312
319
crate_data
313
- . write_package_json ( & out_dir, & None , true , "" , & step)
320
+ . write_package_json ( & out_dir, & None , true , & Target :: Bundler , & step)
314
321
. unwrap ( ) ;
315
322
316
323
let pkg = utils:: manifest:: read_package_json ( & fixture. path , & out_dir) . unwrap ( ) ;
@@ -327,7 +334,7 @@ fn it_sets_homepage_field_if_available_in_cargo_toml() {
327
334
let step = wasm_pack:: progressbar:: Step :: new ( 2 ) ;
328
335
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
329
336
crate_data
330
- . write_package_json ( & out_dir, & None , true , "" , & step)
337
+ . write_package_json ( & out_dir, & None , true , & Target :: Bundler , & step)
331
338
. unwrap ( ) ;
332
339
333
340
let pkg = utils:: manifest:: read_package_json ( & fixture. path , & out_dir) . unwrap ( ) ;
@@ -430,7 +437,7 @@ fn it_lists_license_files_in_files_field_of_package_json() {
430
437
wasm_pack:: command:: utils:: create_pkg_dir ( & out_dir, & step) . unwrap ( ) ;
431
438
license:: copy_from_crate ( & crate_data, & fixture. path , & out_dir, & step) . unwrap ( ) ;
432
439
crate_data
433
- . write_package_json ( & out_dir, & None , false , "" , & step)
440
+ . write_package_json ( & out_dir, & None , false , & Target :: Bundler , & step)
434
441
. unwrap ( ) ;
435
442
436
443
let package_json_path = & fixture. path . join ( "pkg" ) . join ( "package.json" ) ;
0 commit comments