Skip to content

Commit

Permalink
Remove nodejs workaround
Browse files Browse the repository at this point in the history
Users should install the nodejs-legacy package on Debian-based distributions.
  • Loading branch information
micbou committed Aug 5, 2018
1 parent c5ba63a commit f7096cb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 43 deletions.
7 changes: 2 additions & 5 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,8 @@ def EnableRustCompleter( args ):


def EnableJavaScriptCompleter( args ):
# On Debian-based distributions, node is by default installed as nodejs.
node = PathToFirstExistingExecutable( [ 'nodejs', 'node' ] )
if not node:
sys.exit( 'ERROR: node is required to set up Tern.' )
npm = FindExecutableOrDie( 'npm', 'ERROR: npm is required to set up Tern.' )
node = FindExecutableOrDie( 'node', 'node is required to set up Tern.' )
npm = FindExecutableOrDie( 'npm', 'npm is required to set up Tern.' )

# We install Tern into a runtime directory. This allows us to control
# precisely the version (and/or git commit) that is used by ycmd. We use a
Expand Down
3 changes: 1 addition & 2 deletions ycmd/completers/javascript/tern_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
'bin',
'tern' ) )

# On Debian-based distributions, node is by default installed as nodejs.
PATH_TO_NODE = utils.PathToFirstExistingExecutable( [ 'nodejs', 'node' ] )
PATH_TO_NODE = utils.FindExecutable( 'node' )

# host name/address on which the tern server should listen
# note: we use 127.0.0.1 rather than localhost because on some platforms
Expand Down
26 changes: 2 additions & 24 deletions ycmd/completers/typescript/typescript_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@

RESPONSE_TIMEOUT_SECONDS = 10

# On Debian-based distributions, node is by default installed as nodejs.
PATH_TO_NODE = utils.PathToFirstExistingExecutable( [ 'nodejs', 'node' ] )
PATH_TO_TSSERVER = utils.FindExecutable( 'tsserver' )

LOGFILE_FORMAT = 'tsserver_'
Expand Down Expand Up @@ -80,22 +78,7 @@ def result( self ):
return self._message[ 'body' ]


def TsserverCommand():
# Explicitly use node if the TSServer executable is supposed to be run through
# it. This handles the case where node is installed as nodejs.
with open( PATH_TO_TSSERVER ) as f:
first_line = f.readline()
if first_line.startswith( '#!/usr/bin/env node' ):
return [ PATH_TO_NODE, PATH_TO_TSSERVER ]
return [ PATH_TO_TSSERVER ]


def ShouldEnableTypeScriptCompleter():
if not PATH_TO_NODE:
_logger.warning( 'Not using TypeScript completer: unable to find node' )
return False
_logger.info( 'Using node binary from {0}'.format( PATH_TO_NODE ) )

if not PATH_TO_TSSERVER:
_logger.error( 'Not using TypeScript completer: unable to find TSServer.'
'TypeScript 1.5 or higher is required.' )
Expand Down Expand Up @@ -148,7 +131,6 @@ def __init__( self, user_options ):
self._logfile = None

self._tsserver_lock = threading.RLock()
self._tsserver_command = TsserverCommand()
self._tsserver_handle = None
self._tsserver_version = None
# Used to read response only if TSServer is running.
Expand Down Expand Up @@ -208,7 +190,7 @@ def _StartServer( self ):
_logger.info( 'TSServer log file: {0}'.format( self._logfile ) )

# We need to redirect the error stream to the output one on Windows.
self._tsserver_handle = utils.SafePopen( self._tsserver_command,
self._tsserver_handle = utils.SafePopen( PATH_TO_TSSERVER,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
Expand Down Expand Up @@ -848,12 +830,8 @@ def DebugInfo( self, request_data ):
logfiles = [ self._logfile ],
extras = [ item_version ] )

node_executable = responses.DebugInfoItem( key = 'Node executable',
value = PATH_TO_NODE )

return responses.BuildDebugInfoResponse( name = 'TypeScript',
servers = [ tsserver ],
items = [ node_executable ] )
servers = [ tsserver ] )


def _LogLevel():
Expand Down
8 changes: 1 addition & 7 deletions ycmd/tests/typescript/debug_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ def DebugInfo_test( app ):
'key': 'version',
'value': any_of( None, instance_of( str ) )
} ) )
} ) ),
'items': contains(
has_entries( {
'key': 'Node executable',
'value': instance_of( str )
} )
)
} ) )
} ) )
)
5 changes: 0 additions & 5 deletions ycmd/tests/typescript/typescript_completer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def ShouldEnableTypeScriptCompleter_NodeAndTsserverFound_test():
ok_( ShouldEnableTypeScriptCompleter() )


@patch( 'ycmd.completers.typescript.typescript_completer.PATH_TO_NODE', None )
def ShouldEnableTypeScriptCompleter_NodeNotFound_test( *args ):
ok_( not ShouldEnableTypeScriptCompleter() )


@patch( 'ycmd.completers.typescript.typescript_completer.PATH_TO_TSSERVER',
None )
def ShouldEnableTypeScriptCompleter_TsserverNotFound_test( *args ):
Expand Down

0 comments on commit f7096cb

Please sign in to comment.