File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,30 @@ describe("Simple Git Hooks tests", () => {
361361 expect ( isEqual ( installedHooks , { } ) ) . toBe ( true ) ;
362362 } ) ;
363363
364+ it ( "only removes git hooks which are not in preserveUnused" , ( ) => {
365+ createGitHooksFolder ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
366+
367+ const installedHooksDir = path . normalize (
368+ path . join ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
369+ ) ;
370+
371+ fs . writeFileSync (
372+ path . resolve ( installedHooksDir , "commit-msg" ) ,
373+ "# do nothing"
374+ ) ;
375+
376+ let installedHooks = getInstalledGitHooks ( installedHooksDir ) ;
377+
378+ expect ( isEqual ( installedHooks , { "commit-msg" : "# do nothing" } ) ) . toBe ( true ) ;
379+
380+ simpleGitHooks . setHooksFromConfig ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
381+
382+ simpleGitHooks . removeHooks ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
383+
384+ installedHooks = getInstalledGitHooks ( installedHooksDir ) ;
385+ expect ( isEqual ( installedHooks , { "commit-msg" : "# do nothing" } ) ) . toBe ( true ) ;
386+ } ) ;
387+
364388 it ( "creates git hooks and removes unused git hooks" , ( ) => {
365389 createGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
366390
You can’t perform that action at this time.
0 commit comments