cygwin64.ts 903 B

123456789101112131415161718192021222324252627282930313233343536
  1. import * as path from 'path'
  2. import { Injectable } from '@angular/core'
  3. import { getRegistryValue } from 'windows-native-registry'
  4. import { HostAppService, Platform } from 'terminus-core'
  5. import { ShellProvider, IShell } from '../api'
  6. @Injectable()
  7. export class Cygwin64ShellProvider 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 = getRegistryValue('HKLM', 'Software\\Cygwin\\setup', 'rootdir')
  18. if (!cygwinPath) {
  19. return []
  20. }
  21. return [{
  22. id: 'cygwin64',
  23. name: 'Cygwin',
  24. command: path.join(cygwinPath, 'bin', 'bash.exe'),
  25. env: {
  26. TERM: 'cygwin',
  27. }
  28. }]
  29. }
  30. }