( command: string, args: string[], write: (text: string) => void )
| 159 | } |
| 160 | |
| 161 | function runNpmUpdateCommand( |
| 162 | command: string, |
| 163 | args: string[], |
| 164 | write: (text: string) => void |
| 165 | ): Promise<UpdateCommandResult> { |
| 166 | return new Promise((resolve) => { |
| 167 | const child = execFile(command, args, { timeout: 120_000 }, (err, _stdout, stderr) => { |
| 168 | if (err) { |
| 169 | resolve({ success: false, error: stderr || err.message }) |
| 170 | } else { |
| 171 | resolve({ success: true }) |
| 172 | } |
| 173 | }) |
| 174 | child.stdout?.on('data', (chunk) => write(String(chunk))) |
| 175 | child.stderr?.on('data', (chunk) => write(String(chunk))) |
| 176 | }) |
| 177 | } |
| 178 | |
| 179 | export function performCliSelfUpdate(options: PerformCliSelfUpdateOptions = {}): Promise<UpdateCommandResult> { |
| 180 | const platformName = options.platform ?? process.platform |
no test coverage detected