( scripts: Record<string, string> | undefined, )
| 90 | * @returns Info about install scripts and npx dependencies, or null if no install scripts |
| 91 | */ |
| 92 | export function extractInstallScriptsInfo( |
| 93 | scripts: Record<string, string> | undefined, |
| 94 | ): InstallScriptsInfo | null { |
| 95 | if (!scripts) return null |
| 96 | |
| 97 | const presentScripts: ('preinstall' | 'install' | 'postinstall')[] = [] |
| 98 | const content: Record<string, string> = {} |
| 99 | |
| 100 | for (const scriptName of INSTALL_SCRIPTS) { |
| 101 | if (scripts[scriptName]) { |
| 102 | presentScripts.push(scriptName as 'preinstall' | 'install' | 'postinstall') |
| 103 | content[scriptName] = scripts[scriptName] |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if (presentScripts.length === 0) return null |
| 108 | |
| 109 | return { |
| 110 | scripts: presentScripts, |
| 111 | content, |
| 112 | npxDependencies: extractNpxDependencies(scripts), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Pattern to match scripts that are just `node <file-path>` |
no test coverage detected