File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed
Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ branding:
44 icon : " chevron-right"
55 color : " gray-dark"
66runs :
7- using : " node12 "
7+ using : " node16 "
88 main : " index.js"
Original file line number Diff line number Diff line change 11const checkLockVersion = require ( "./lib/checks/lockVersion" ) ;
22const checkForPreRelease = require ( "./lib/checks/preReleases" ) ;
3+ const checkForWorkspaces = require ( "./lib/checks/workspaces" ) ;
34const hasYarnLock = require ( "./lib/checks/yarn" ) ;
45const { FatalError } = require ( "./lib/errors" ) ;
56const { getPackageLock, getPackage } = require ( "./lib/utils" ) ;
@@ -11,6 +12,7 @@ function lint() {
1112 errors . push ( hasYarnLock ( ) ) ;
1213 errors . push ( checkLockVersion ( pkgLock ) ) ;
1314 errors . push ( checkForPreRelease ( pkgJson ) ) ;
15+ errors . push ( checkForWorkspaces ( pkgJson ) ) ;
1416 for ( const error of errors ) {
1517 if ( error instanceof FatalError ) {
1618 process . stderr . write ( `${ error . message } \n` ) ;
Original file line number Diff line number Diff line change 1+ const { FatalError } = require ( "../errors" ) ;
2+ const checkForWorkspaces = require ( "../checks/workspaces" ) ;
3+
4+ describe ( "Check workspaces" , ( ) => {
5+ it ( "should not return a fatal error when no workspaces are defined" , ( ) => {
6+ const result = checkForWorkspaces ( {
7+ dependencies : {
8+ "@mobsuccess-devops/pre-release" : "1.0.0-pr-1.0" ,
9+ } ,
10+ } ) ;
11+ expect ( result ) . toBeUndefined ( ) ;
12+ } ) ;
13+ it ( "should not return a fatal error when workspaces are empty" , ( ) => {
14+ const result = checkForWorkspaces ( { workspaces : [ ] } ) ;
15+ expect ( result ) . toBeUndefined ( ) ;
16+ } ) ;
17+ it ( "should return a fatal error when workspaces are not empty" , ( ) => {
18+ const result = checkForWorkspaces ( { workspaces : [ "../react-ui" ] } ) ;
19+ expect ( result ) . toBeInstanceOf ( FatalError ) ;
20+ } ) ;
21+ } ) ;
Original file line number Diff line number Diff line change 1+ const { FatalError } = require ( "../errors" ) ;
2+
3+ function checkForWorkspaces ( pkgJson = { } ) {
4+ const { workspaces = [ ] } = pkgJson ;
5+ if ( workspaces . length > 0 ) {
6+ return new FatalError ( `Unexpected workspaces found: ${ workspaces } \n` ) ;
7+ }
8+ }
9+
10+ module . exports = checkForWorkspaces ;
You can’t perform that action at this time.
0 commit comments