Skip to content

Commit e551045

Browse files
committed
Try to run yarn if npm failed
1 parent 6b2aa89 commit e551045

File tree

1 file changed

+8
-2
lines changed
  • src/fosslight_dependency/package_manager

1 file changed

+8
-2
lines changed

src/fosslight_dependency/package_manager/Npm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ def start_license_checker(self):
5353
self.flag_tmp_node_modules = True
5454
cmd_ret = subprocess.call(npm_install_cmd, shell=True)
5555
if cmd_ret != 0:
56-
logger.error(f"{npm_install_cmd} returns an error")
57-
return False
56+
logger.warning(f"{npm_install_cmd} returns an error. Trying yarn as fallback...")
57+
yarn_install_cmd = 'yarn install --production --ignore-scripts'
58+
cmd_ret = subprocess.call(yarn_install_cmd, shell=True)
59+
if cmd_ret != 0:
60+
logger.error(f"Both {npm_install_cmd} and {yarn_install_cmd} failed")
61+
return False
62+
else:
63+
logger.info(f"Successfully executed {yarn_install_cmd}")
5864

5965
# customized json file for obtaining specific items with license-checker
6066
self.make_custom_json(self.tmp_custom_json)

0 commit comments

Comments
 (0)