@@ -11,6 +11,7 @@ jest.mock("../../version/lib/is-anything-committed");
11
11
jest . mock ( "../../version/lib/is-behind-upstream" ) ;
12
12
jest . mock ( "../../version/lib/remote-branch-exists" ) ;
13
13
14
+ const fs = require ( "fs-extra" ) ;
14
15
const path = require ( "path" ) ;
15
16
16
17
// mocked modules
@@ -70,9 +71,37 @@ describe("licenses", () => {
70
71
await lernaPublish ( cwd ) ( ) ;
71
72
72
73
const [ warning ] = loggingOutput ( "warn" ) ;
73
- expect ( warning ) . toMatch ( "Packages package-1, package-3 are missing a license" ) ;
74
+ expect ( warning ) . toMatchInlineSnapshot ( `
75
+ "Packages package-1 and package-3 are missing a license.
76
+ One way to fix this is to add a LICENSE.md file to the root of this repository.
77
+ See https://choosealicense.com for additional guidance."
78
+ ` ) ;
74
79
75
80
expect ( createTempLicenses ) . toHaveBeenLastCalledWith ( undefined , [ ] ) ;
76
81
expect ( removeTempLicenses ) . toHaveBeenLastCalledWith ( [ ] ) ;
77
82
} ) ;
83
+
84
+ it ( "warns when one package needs a license" , async ( ) => {
85
+ const cwd = await initFixture ( "licenses" ) ;
86
+
87
+ // remove root license so warning is triggered
88
+ await fs . remove ( path . join ( cwd , "LICENSE" ) ) ;
89
+
90
+ await lernaPublish ( cwd ) ( ) ;
91
+
92
+ const [ warning ] = loggingOutput ( "warn" ) ;
93
+ expect ( warning ) . toMatch ( "Package package-1 is missing a license." ) ;
94
+ } ) ;
95
+
96
+ it ( "warns when multiple packages need a license" , async ( ) => {
97
+ const cwd = await initFixture ( "licenses-missing" ) ;
98
+
99
+ // simulate _all_ packages missing a license
100
+ await fs . remove ( path . join ( cwd , "packages/package-2/LICENSE" ) ) ;
101
+
102
+ await lernaPublish ( cwd ) ( ) ;
103
+
104
+ const [ warning ] = loggingOutput ( "warn" ) ;
105
+ expect ( warning ) . toMatch ( "Packages package-1, package-2, and package-3 are missing a license." ) ;
106
+ } ) ;
78
107
} ) ;
0 commit comments