@@ -449,6 +449,59 @@ describe("Simple Git Hooks tests", () => {
449
449
expect ( isEqual ( installedHooks , COMMON_GIT_HOOKS ) ) . toBe ( true ) ;
450
450
} ) ;
451
451
} ) ;
452
+
453
+ describe ( "SKIP_INSTALL_SIMPLE_GIT_HOOKS" , ( ) => {
454
+ afterEach ( ( ) => {
455
+ removeGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
456
+ } ) ;
457
+
458
+ it ( "does not create git hooks when SKIP_INSTALL_SIMPLE_GIT_HOOKS is set to 1" , ( ) => {
459
+ createGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
460
+ execSync ( `node ${ require . resolve ( "./cli" ) } ` , {
461
+ cwd : PROJECT_WITH_CONF_IN_PACKAGE_JSON ,
462
+ env : {
463
+ ...process . env ,
464
+ SKIP_INSTALL_SIMPLE_GIT_HOOKS : "1" ,
465
+ } ,
466
+ } ) ;
467
+ const installedHooks = getInstalledGitHooks (
468
+ path . normalize (
469
+ path . join ( PROJECT_WITH_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
470
+ )
471
+ ) ;
472
+ expect ( installedHooks ) . toEqual ( { } ) ;
473
+ } ) ;
474
+
475
+ it ( "creates git hooks when SKIP_INSTALL_SIMPLE_GIT_HOOKS is set to 0" , ( ) => {
476
+ createGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
477
+ execSync ( `node ${ require . resolve ( "./cli" ) } ` , {
478
+ cwd : PROJECT_WITH_CONF_IN_PACKAGE_JSON ,
479
+ env : {
480
+ ...process . env ,
481
+ SKIP_INSTALL_SIMPLE_GIT_HOOKS : "0" ,
482
+ } ,
483
+ } ) ;
484
+ const installedHooks = getInstalledGitHooks (
485
+ path . normalize (
486
+ path . join ( PROJECT_WITH_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
487
+ )
488
+ ) ;
489
+ expect ( installedHooks ) . toEqual ( { "pre-commit" : TEST_SCRIPT } ) ;
490
+ } ) ;
491
+
492
+ it ( "creates git hooks when SKIP_INSTALL_SIMPLE_GIT_HOOKS is not set" , ( ) => {
493
+ createGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
494
+ execSync ( `node ${ require . resolve ( "./cli" ) } ` , {
495
+ cwd : PROJECT_WITH_CONF_IN_PACKAGE_JSON ,
496
+ } ) ;
497
+ const installedHooks = getInstalledGitHooks (
498
+ path . normalize (
499
+ path . join ( PROJECT_WITH_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
500
+ )
501
+ ) ;
502
+ expect ( installedHooks ) . toEqual ( { "pre-commit" : TEST_SCRIPT } ) ;
503
+ } ) ;
504
+ } ) ;
452
505
} ) ;
453
506
454
507
describe ( "ENV vars features tests" , ( ) => {
0 commit comments