File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,41 @@ describe('fails with incorrect configuration', () => {
4747 cwd : '/' ,
4848 } ) ,
4949 ) . rejects . toThrowErrorMatchingInlineSnapshot (
50- `"rollpkg requires a \\"build\\" or \\"watch\\" command with no arguments, received: \\"\\""` ,
50+ `"rollpkg requires a \\"build\\" or \\"watch\\" command, received: \\"\\""` ,
51+ ) ;
52+ } ) ;
53+
54+ test ( 'fails with "watch" command and "--addUmdBuild" options' , async ( ) => {
55+ mockFs ( {
56+ '/package.json' : JSON . stringify ( createTestPackageJson ( ) ) ,
57+ '/tsconfig.json' : '' ,
58+ '/src/index.ts' : '' ,
59+ } ) ;
60+
61+ await expect (
62+ checkInvariantsAndGetConfiguration ( {
63+ args : [ 'watch' , '--addUmdBuild' ] ,
64+ cwd : '/' ,
65+ } ) ,
66+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
67+ `"--addUmdBuild option is not valid in watch mode (only the esm build is created in watch mode)"` ,
68+ ) ;
69+ } ) ;
70+
71+ test ( 'fails with "watch" command and "--noStats" options' , async ( ) => {
72+ mockFs ( {
73+ '/package.json' : JSON . stringify ( createTestPackageJson ( ) ) ,
74+ '/tsconfig.json' : '' ,
75+ '/src/index.ts' : '' ,
76+ } ) ;
77+
78+ await expect (
79+ checkInvariantsAndGetConfiguration ( {
80+ args : [ 'watch' , '--noStats' ] ,
81+ cwd : '/' ,
82+ } ) ,
83+ ) . rejects . toThrowErrorMatchingInlineSnapshot (
84+ `"--noStats option is not valid in watch mode (stats are never calculated in watch mode)"` ,
5185 ) ;
5286 } ) ;
5387
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export const checkInvariantsAndGetConfiguration: ConfigureRollpkg = async ({
3131} ) => {
3232 invariant (
3333 args [ 0 ] === 'build' || args [ 0 ] === 'watch' ,
34- `rollpkg requires a "build" or "watch" command with no arguments , received: "${ args . join (
34+ `rollpkg requires a "build" or "watch" command, received: "${ args . join (
3535 ' ' ,
3636 ) } "`,
3737 ) ;
@@ -50,7 +50,16 @@ export const checkInvariantsAndGetConfiguration: ConfigureRollpkg = async ({
5050 }
5151
5252 const addUmdBuild = args . includes ( '--addUmdBuild' ) ;
53+ invariant (
54+ ! watchMode || ( watchMode && ! addUmdBuild ) ,
55+ '--addUmdBuild option is not valid in watch mode (only the esm build is created in watch mode)' ,
56+ ) ;
57+
5358 const includeBundlephobiaStats = ! args . includes ( '--noStats' ) ;
59+ invariant (
60+ ! watchMode || ( watchMode && includeBundlephobiaStats ) ,
61+ '--noStats option is not valid in watch mode (stats are never calculated in watch mode)' ,
62+ ) ;
5463
5564 interface PkgJson extends PackageJson {
5665 umdGlobalDependencies ?: { [ key : string ] : string } ;
You can’t perform that action at this time.
0 commit comments