# Path: lib/utils/fileutils.py
# def file_exists(filename):
#     """ returns weather the file exists """
#     return os.path.isfile(os.path.normcase(filename))
# 
# Path: lib/utils/utils.py
# def replace_variables(value, variables):
#     if hasattr(sublime, 'expand_variables'): # ST3, Build 3068
#         # stringify dict
#         for k in variables.keys():
#             variables[k] = str(variables[k]);
#         return sublime.expand_variables(value, variables)
#     else:
#         # sort keys after length, to get $file_path before $file
#         keys = list(variables.keys())
#         keys.sort(key=len, reverse=True)
#         for k in keys:
#             key = "${%s}" % k
#             if key in value:
#                 value = value.replace(key, str(variables[k]))
#     return value
# 
# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()


import os
import sys
from .fileutils import file_exists
from .utils import replace_variables
from .debug import Debug
# coding=utf8




# PACKAGE PATH
package_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))


def add_usr_local_bin_to_path_on_osx():
    """ OBSOLETE
        Adds /usr/local/bin to path on mac osx, because that is
        where nodejs lives.
        This function has not worked out its intension. Popen does not
        use this PATH as a search base for the executable.
        default_node_path() is back to it's previous state."""
    if os.environ.get('PATH') and sys.platform == 'darwin':
        if '/usr/local/bin' in os.environ.get('PATH').split(':'):
            os.environ['PATH'] = os.environ.get('PATH') + ":'/usr/local/bin'"

def find_tsconfigdir(rootdir):
    """ Returns the normalized dir, in which the tsconfig.json file is located"""
    rootdir = os.path.abspath(rootdir)
    try:

# Path: lib/utils/fileutils.py
# def file_exists(filename):
#     """ returns weather the file exists """
#     return os.path.isfile(os.path.normcase(filename))
# 
# Path: lib/utils/utils.py
# def replace_variables(value, variables):
#     if hasattr(sublime, 'expand_variables'): # ST3, Build 3068
#         # stringify dict
#         for k in variables.keys():
#             variables[k] = str(variables[k]);
#         return sublime.expand_variables(value, variables)
#     else:
#         # sort keys after length, to get $file_path before $file
#         keys = list(variables.keys())
#         keys.sort(key=len, reverse=True)
#         for k in keys:
#             key = "${%s}" % k
#             if key in value:
#                 value = value.replace(key, str(variables[k]))
#     return value
# 
# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()


# Path: lib/utils/pathutils.py
import os
import sys
from .fileutils import file_exists
from .utils import replace_variables
from .debug import Debug

# coding=utf8




# PACKAGE PATH
package_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))


def add_usr_local_bin_to_path_on_osx():
    """ OBSOLETE
        Adds /usr/local/bin to path on mac osx, because that is
        where nodejs lives.
        This function has not worked out its intension. Popen does not
        use this PATH as a search base for the executable.
        default_node_path() is back to it's previous state."""
    if os.environ.get('PATH') and sys.platform == 'darwin':
        if '/usr/local/bin' in os.environ.get('PATH').split(':'):
            os.environ['PATH'] = os.environ.get('PATH') + ":'/usr/local/bin'"

def find_tsconfigdir(rootdir):
    """ Returns the normalized dir, in which the tsconfig.json file is located"""
    rootdir = os.path.abspath(rootdir)
    try:

        if file_exists(os.path.join(rootdir, "tsconfig.json")):