cygwin32.ts 907 B

123456789101112131415161718192021222324252627282930313233343536
  1. import * as path from 'path'
  2. import { Injectable } from '@angular/core'
  3. import { Registry } from 'rage-edit-tmp'
  4. import { HostAppService, Platform } from 'terminus-core'
  5. import { ShellProvider, IShell } from '../api'
  6. @Injectable()
  7. export class Cygwin32ShellProvider extends ShellProvider {
  8. constructor (
  9. private hostApp: HostAppService,
  10. ) {
  11. super()
  12. }
  13. async provide (): Promise<IShell[]> {
  14. if (this.hostApp.platform !== Platform.Windows) {
  15. return []
  16. }
  17. let cygwinPath = await Registry.get('HKLM\\Software\\WOW6432Node\\Cygwin\\setup', 'rootdir')
  18. if (!cygwinPath) {
  19. return []
  20. }
  21. return [{
  22. id: 'cygwin32',
  23. name: 'Cygwin (32 bit)',
  24. command: path.join(cygwinPath, 'bin', 'bash.exe'),
  25. env: {
  26. TERM: 'cygwin',
  27. }
  28. }]
  29. }
  30. }