Module: Cline::Utils::Os::Mingw32

Defined in:
lib/cline/utils/os/mingw32.rb

Overview

OS utils for host OS mingw32

Instance Method Summary collapse

Instance Method Details

#cline_exeArray<String>

Returns The Cline executable command line (can also have some arguments).

Returns:

  • (Array<String>)

    The Cline executable command line (can also have some arguments)



24
25
26
27
28
29
30
31
32
# File 'lib/cline/utils/os/mingw32.rb', line 24

def cline_exe
  # As this CLI will be used with PTY.spawn and we want multiline support,
  # don't use cline.cmd npm wrapper as it treats "\n" as new command lines.
  # Therefore we use the node.exe binary directly.
  @cline_exe ||= [
    'node.exe',
    "#{::File.dirname(`where cline.cmd`.split("\n").first)}/node_modules/cline/bin/cline"
  ]
end

#kill(pid) ⇒ Object

Kill a process. Handles errors gracefully in case the process has already disappeared.

Parameters:

  • pid (Integer)

    Process to kill



17
18
19
20
21
# File 'lib/cline/utils/os/mingw32.rb', line 17

def kill(pid)
  # Don't use Process.kill on Windows, because the killed process will have an exit status 0, which is incorrect.
  # TODO: Use Process.kill here when Process.kill will be fixed on Windows systems.
  system("taskkill /f /pid #{pid}")
end

#max_cmd_lengthInteger

Returns Maximum length a command line can have.

Returns:

  • (Integer)

    Maximum length a command line can have



40
41
42
# File 'lib/cline/utils/os/mingw32.rb', line 40

def max_cmd_length
  8191
end

#user_app_data_dirString

Returns The user applications data directory.

Returns:

  • (String)

    The user applications data directory



35
36
37
# File 'lib/cline/utils/os/mingw32.rb', line 35

def user_app_data_dir
  ENV['APPDATA'] || raise('APPDATA environment variable should be set to know the applications data dir')
end

#user_home_dirString

Get the user home directory path

Returns:

  • (String)

    Normalized absolute path to user home directory



9
10
11
# File 'lib/cline/utils/os/mingw32.rb', line 9

def user_home_dir
  ENV['USERPROFILE'].gsub('\\', '/')
end