Add functionality to truncate via composer.json
This commit is contained in:
parent
a0aa5ccbfc
commit
ec044c028a
2 changed files with 11 additions and 2 deletions
|
@ -655,7 +655,16 @@ prompt_dir() {
|
|||
subdirectory_path=$(truncatePathFromRight "${current_dir:${#${(S%%)package_path//$~zero/}}}")
|
||||
# Parse the 'name' from the package.json; if there are any problems, just
|
||||
# print the file path
|
||||
local pkgFile="${package_path}/package.json"
|
||||
defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)
|
||||
|
||||
local pkgFile="unknown"
|
||||
for file in "${POWERLEVEL9K_DIR_PACKAGE_FILES[@]}"; do
|
||||
if [[ -f "${package_path}/${file}" ]]; then
|
||||
pkgFile="${package_path}/${file}"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
local packageName=$(jq '.name' ${pkgFile} 2> /dev/null \
|
||||
|| node -e 'console.log(require(process.argv[1]).name);' ${pkgFile} 2>/dev/null \
|
||||
|| cat "${pkgFile}" 2> /dev/null | grep -m 1 "\"name\"" | awk -F ':' '{print $2}' | awk -F '"' '{print $2}' 2>/dev/null \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue