Skip to content

Commit

Permalink
adding option to specify a custom lock file to be copied over pre-ins…
Browse files Browse the repository at this point in the history
…tall
  • Loading branch information
emarteca committed Jul 7, 2023
1 parent 7d2f03b commit 76be9c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/diagnose_github_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RepoWalker():
RM_AFTER_CLONING = False
SCRIPTS_OVER_CODE = []
CUSTOM_SETUP_SCRIPTS = []
CUSTOM_LOCK_FILES = []
QL_QUERIES = []

DO_INSTALL = True
Expand Down Expand Up @@ -93,6 +94,8 @@ def set_up_config( self, config_file):
cf_dict = config_json.get( "install", {})
self.DO_INSTALL = cf_dict.get("do_install", self.DO_INSTALL)
self.INSTALL_TIMEOUT = cf_dict.get("timeout", self.INSTALL_TIMEOUT)
self.CUSTOM_LOCK_FILES = [ os.path.abspath(os.path.dirname(config_file if config_file else __file__)) + "/" + p
for p in cf_dict.get( "custom_lock_files", self.CUSTOM_LOCK_FILES)]

cf_dict = config_json.get( "build", {})
self.TRACK_BUILD = cf_dict.get("track_build", self.TRACK_BUILD)
Expand Down
3 changes: 3 additions & 0 deletions src/diagnose_npm_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NPMSpider(scrapy.Spider):
RM_AFTER_CLONING = False
SCRIPTS_OVER_CODE = []
CUSTOM_SETUP_SCRIPTS = []
CUSTOM_LOCK_FILES = []
QL_QUERIES = []

DO_INSTALL = True
Expand Down Expand Up @@ -85,6 +86,8 @@ def set_up_config( self, config_file):
cf_dict = config_json.get( "install", {})
self.DO_INSTALL = cf_dict.get("do_install", self.DO_INSTALL)
self.INSTALL_TIMEOUT = cf_dict.get("timeout", self.INSTALL_TIMEOUT)
self.CUSTOM_LOCK_FILES = [ os.path.abspath(os.path.dirname(config_file if config_file else __file__)) + "/" + p
for p in cf_dict.get( "custom_lock_files", self.CUSTOM_LOCK_FILES)]

cf_dict = config_json.get( "build", {})
self.TRACK_BUILD = cf_dict.get("track_build", self.TRACK_BUILD)
Expand Down
5 changes: 5 additions & 0 deletions src/test_JS_repo_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ def diagnose_package( repo_link, crawler, commit_SHA=None):
return( on_diagnose_exit( json_out, crawler, cur_dir, repo_name))

manager = ""
# if there's custom lock files, copy them into the repo (repo is "." since we're in the repo currently)
if crawler.CUSTOM_LOCK_FILES != []:
for custom_lock in crawler.CUSTOM_LOCK_FILES:
run_command("cp " + custom_lock + " .")

# first, check if there is a custom install
# this runs custom scripts the same way as the scripts_over_code below; only
# difference is it's before the npm-filter run
Expand Down

0 comments on commit 76be9c1

Please sign in to comment.