Skip to content

Commit a1ced4e

Browse files
committed
fix: install NG CLI globally
NativeScript/nativescript-schematics#214 require global installation of NG CLI. Since we do not rely heavily on NG CLI I suggest insalling it globally. If we encounter troubles we may try local install and custom NPM prefix.
1 parent d461daf commit a1ced4e

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

core/utils/npm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Npm(object):
1414
@staticmethod
1515
def run_npm_command(cmd, folder=Settings.TEST_RUN_HOME, verify=True):
1616
command = 'npm {0}'.format(cmd).strip()
17-
Log.info(command + " (at " + folder + ").")
17+
Log.info(command + " (at " + str(folder) + ").")
1818
result = run(cmd=command, cwd=folder, wait=True, timeout=300)
1919
if verify:
2020
assert result.exit_code == 0, '" + command + " exited with non zero exit code!: \n' + result.output
@@ -48,7 +48,7 @@ def pack(folder, output_file):
4848
File.delete(src_file)
4949

5050
@staticmethod
51-
def install(package='', option='', folder=None):
51+
def install(package='', option='', folder=Settings.TEST_RUN_HOME):
5252
if package is None:
5353
raise NameError('Package can not be None.')
5454
command = 'i {0} {1}'.format(package, option)
@@ -57,7 +57,7 @@ def install(package='', option='', folder=None):
5757
return output
5858

5959
@staticmethod
60-
def uninstall(package, option='', folder=None):
60+
def uninstall(package, option='', folder=Settings.TEST_RUN_HOME):
6161
if package is None or package == '':
6262
raise NameError('Package can not be None.')
6363
return Npm.run_npm_command('un {0} {1}'.format(package, option), folder=folder)

run_common.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,10 @@ def __install_ns_cli():
105105

106106
def __install_ng_cli():
107107
"""
108-
Install Angular CLI locally.
108+
Install Angular CLI globally.
109109
"""
110-
Npm.install(package=Settings.Packages.NG_CLI, folder=Settings.TEST_RUN_HOME)
111-
112-
# Verify executable exists after install
113-
path = os.path.join(Settings.TEST_RUN_HOME, 'node_modules', '.bin', 'ng')
114-
assert File.exists(path), 'Angular CLI executable not found at ' + path
115-
Settings.Executables.NG = path
110+
Npm.uninstall(package='@angular/cli', option='-g')
111+
Npm.install(package=Settings.Packages.NG_CLI, option='-g')
116112

117113

118114
def __install_schematics():

0 commit comments

Comments
 (0)