Skip to content

Commit

Permalink
Add support for dependencies.json in hidden packages
Browse files Browse the repository at this point in the history
This commit includes hidden sublime packages into lookup paths
for required libraries.
  • Loading branch information
deathaxe committed Dec 3, 2023
1 parent faf9e40 commit 3780c37
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 5 additions & 2 deletions package_control/package_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ def create_empty_file(filename):
return True


def list_sublime_package_dirs(path):
def list_sublime_package_dirs(path, include_hidden=False):
"""
Return a set of directories in the folder specified that are not
hidden and are not marked to be removed
:param path:
The folder to list the directories inside of
:param include_hidden:
If True, also return hidden packages
:return:
A generator of directory names
"""
Expand All @@ -51,7 +54,7 @@ def list_sublime_package_dirs(path):
if not os.path.isdir(file_path):
continue
# Don't include hidden packages
if os.path.exists(os.path.join(file_path, '.hidden-sublime-package')):
if not include_hidden and os.path.exists(os.path.join(file_path, '.hidden-sublime-package')):
continue
# Don't include a dir if it is going to be cleaned up
if os.path.exists(os.path.join(file_path, 'package-control.cleanup')):
Expand Down
20 changes: 15 additions & 5 deletions package_control/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,18 +762,25 @@ def list_libraries(self):

return library.list_all()

def list_packages(self, ignored_packages=None, unpacked_only=False):
def list_packages(self, ignored_packages=None, unpacked_only=False, include_hidden=False):
"""
List installed packages on the machine
:param ignored_packages:
A list of packages to ignore in returned result.
The default value ``None`` or an empty list disables filtering.
:param unpacked_only:
Only list packages that are not inside of .sublime-package files
:param include_hidden:
If True, also return hidden packages
:return:
A set of all installed or overridden default package names
"""

packages = set(list_sublime_package_dirs(sys_path.packages_path()))
packages = set(list_sublime_package_dirs(sys_path.packages_path(), include_hidden))
if unpacked_only is False:
packages |= set(list_sublime_package_files(sys_path.installed_packages_path()))
if ignored_packages:
Expand All @@ -793,15 +800,18 @@ def list_default_packages(self):
packages -= {'User'}
return packages

def list_all_packages(self):
def list_all_packages(self, include_hidden=False):
"""
Lists all packages on the machine
:param include_hidden:
If True, also return hidden packages
:return:
A set of all package names, including default packages
"""

packages = set(list_sublime_package_dirs(sys_path.packages_path()))
packages = set(list_sublime_package_dirs(sys_path.packages_path(), include_hidden))
packages |= set(list_sublime_package_files(sys_path.installed_packages_path()))
packages |= set(list_sublime_package_files(sys_path.default_packages_path()))
packages -= {'User'}
Expand Down Expand Up @@ -914,7 +924,7 @@ def find_required_libraries(self):
"""

output = set()
for package in self.list_packages():
for package in self.list_packages(include_hidden=True):
output |= self.get_libraries(package)

output |= self.get_libraries('User')
Expand Down

0 comments on commit 3780c37

Please sign in to comment.