mirror of
				https://github.com/easingthemes/ssh-deploy.git
				synced 2025-10-30 23:30:09 +08:00 
			
		
		
		
	Merge pull request #119 from easingthemes/bugfix/#118-default-value-check
fix: #118 check undefined default values
This commit is contained in:
		
						commit
						e7b2312bc9
					
				| @ -10,7 +10,11 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE; | |||||||
| const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER; | const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER; | ||||||
| 
 | 
 | ||||||
| const defaultInputs = { | const defaultInputs = { | ||||||
|  |   source: '', | ||||||
|   target: `/home/${remoteUser}/`, |   target: `/home/${remoteUser}/`, | ||||||
|  |   exclude: '', | ||||||
|  |   args: '-rlgoDzvc -i', | ||||||
|  |   sshCmdArgs: '-o StrictHostKeyChecking=no', | ||||||
|   deployKeyName: `deploy_key_${remoteUser}_${Date.now()}` |   deployKeyName: `deploy_key_${remoteUser}_${Date.now()}` | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -21,18 +25,19 @@ const inputs = { | |||||||
| inputNames.forEach((input) => { | inputNames.forEach((input) => { | ||||||
|   const inputName = snakeToCamel(input.toLowerCase()); |   const inputName = snakeToCamel(input.toLowerCase()); | ||||||
|   const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName]; |   const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName]; | ||||||
|   let extendedVal = inputVal; |   const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal; | ||||||
|  |   let extendedVal = validVal; | ||||||
|   // eslint-disable-next-line default-case
 |   // eslint-disable-next-line default-case
 | ||||||
|   switch (inputName) { |   switch (inputName) { | ||||||
|     case 'source': |     case 'source': | ||||||
|       extendedVal = inputVal.split(' ').map((src) => `${githubWorkspace}/${src}`); |       extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`); | ||||||
|       break; |       break; | ||||||
|     case 'args': |     case 'args': | ||||||
|       extendedVal = inputVal.split(' '); |       extendedVal = validVal.split(' '); | ||||||
|       break; |       break; | ||||||
|     case 'exclude': |     case 'exclude': | ||||||
|     case 'sshCmdArgs': |     case 'sshCmdArgs': | ||||||
|       extendedVal = inputVal.split(',').map((item) => item.trim()); |       extendedVal = validVal.split(',').map((item) => item.trim()); | ||||||
|       break; |       break; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Dragan Filipović
						Dragan Filipović