mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-31 15:26:23 +07:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										8
									
								
								node_modules/husky/lib/upgrader/bin.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								node_modules/husky/lib/upgrader/bin.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| #!/usr/bin/env node | ||||
| "use strict"; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const index_1 = __importDefault(require("./index")); | ||||
| index_1.default(process.cwd()); | ||||
							
								
								
									
										64
									
								
								node_modules/husky/lib/upgrader/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								node_modules/husky/lib/upgrader/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | ||||
| "use strict"; | ||||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const fs_1 = __importDefault(require("fs")); | ||||
| const path_1 = __importDefault(require("path")); | ||||
| const read_pkg_1 = __importDefault(require("read-pkg")); | ||||
| const hookList = { | ||||
|     applypatchmsg: 'applypatch-msg', | ||||
|     commitmsg: 'commit-msg', | ||||
|     postapplypatch: 'post-applypatch', | ||||
|     postcheckout: 'post-checkout', | ||||
|     postcommit: 'post-commit', | ||||
|     postmerge: 'post-merge', | ||||
|     postreceive: 'post-receive', | ||||
|     postrewrite: 'post-rewrite', | ||||
|     postupdate: 'post-update', | ||||
|     preapplypatch: 'pre-applypatch', | ||||
|     preautogc: 'pre-auto-gc', | ||||
|     precommit: 'pre-commit', | ||||
|     preparecommitmsg: 'prepare-commit-msg', | ||||
|     prepush: 'pre-push', | ||||
|     prerebase: 'pre-rebase', | ||||
|     prereceive: 'pre-receive', | ||||
|     pushtocheckout: 'push-to-checkout', | ||||
|     sendemailvalidate: 'sendemail-validate', | ||||
|     update: 'update' | ||||
| }; | ||||
| function upgrade(cwd) { | ||||
|     const pkgFile = path_1.default.join(cwd, 'package.json'); | ||||
|     if (fs_1.default.existsSync(pkgFile)) { | ||||
|         const pkg = read_pkg_1.default.sync({ cwd, normalize: false }); | ||||
|         console.log(`husky > upgrading ${pkgFile}`); | ||||
|         // Don't overwrite 'husky' field if it exists | ||||
|         if (pkg.husky) { | ||||
|             return console.log(`husky field in package.json isn't empty, skipping automatic upgrade`); | ||||
|         } | ||||
|         const hooks = {}; | ||||
|         // Find hooks in package.json 'scripts' field | ||||
|         Object.keys(hookList).forEach((name) => { | ||||
|             if (pkg.scripts) { | ||||
|                 const script = pkg.scripts[name]; | ||||
|                 if (script) { | ||||
|                     delete pkg.scripts[name]; | ||||
|                     const newName = hookList[name]; | ||||
|                     hooks[newName] = script.replace(/\bGIT_PARAMS\b/g, 'HUSKY_GIT_PARAMS'); | ||||
|                     console.log(`moved scripts.${name} to husky.hooks.${newName}`); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|         // Move found hooks to 'husky.hooks' field | ||||
|         if (Object.keys(hooks).length) { | ||||
|             pkg.husky = { hooks }; | ||||
|         } | ||||
|         else { | ||||
|             console.log('no hooks found'); | ||||
|         } | ||||
|         // Update package.json | ||||
|         fs_1.default.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8'); | ||||
|         console.log(`husky > done`); | ||||
|     } | ||||
| } | ||||
| exports.default = upgrade; | ||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur