mirror of
https://github.com/RyanGreenup/cadmus.git
synced 2025-08-19 04:12:16 +02:00
Start on V2 written in GoLang
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
conlook () {
|
||||
if [[ -f ./.config.json ]]; then
|
||||
CONFIG="./config.json"
|
||||
return
|
||||
elif [[ CONFIG == "" ]]
|
||||
if [[ "$(pwd)" == "/" ]]; then
|
||||
CONFIG="~/.config/cadmus/config.json"
|
||||
else
|
||||
cd ..
|
||||
fi
|
||||
conlook
|
||||
}
|
144
bin/NoteFind.sh
144
bin/NoteFind.sh
@@ -1,144 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
|
||||
# * Shell Settings
|
||||
set -o errexit # abort on nonzero exitstatus
|
||||
set -o nounset # abort on unbound variable
|
||||
set -o pipefail # don't hide errors within pipes
|
||||
|
||||
# * Main Function
|
||||
main() {
|
||||
|
||||
check_for_dependencies
|
||||
setVars
|
||||
readFirstArgument "${@}"
|
||||
SkimNotes "${@}"
|
||||
|
||||
}
|
||||
|
||||
# ** Helper Functions
|
||||
# *** Check for Dependencies
|
||||
check_for_dependencies () {
|
||||
|
||||
for i in "${DependArray[@]}"; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** List of Dependencies
|
||||
|
||||
declare -a DependArray=(
|
||||
"rg"
|
||||
"sk"
|
||||
"mdcat"
|
||||
"xclip"
|
||||
)
|
||||
|
||||
|
||||
# *** Set variables below main
|
||||
setVars () {
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
}
|
||||
|
||||
# **** Print Help
|
||||
Help () {
|
||||
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1mNoteFind.sh \e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m--------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||
echo
|
||||
echo -e " ${script_name} [<path/to/notes>]"
|
||||
echo -e " ${script_name} [-h]"
|
||||
echo -e " ${script_name} [--help]"
|
||||
echo
|
||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
||||
echo
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
||||
echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
||||
echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
||||
echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
||||
echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
||||
echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
||||
echo
|
||||
|
||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** Read First Argument
|
||||
readFirstArgument () {
|
||||
|
||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
||||
Help && exit 0
|
||||
fi
|
||||
|
||||
}
|
||||
# *** Skim and Grep, the important stuff
|
||||
SkimNotes () {
|
||||
|
||||
## Change directory if One was specified, exit if no directory exists
|
||||
|
||||
cd "${1}"
|
||||
|
||||
FILE="$(SkimGrep)"
|
||||
if [[ $FILE != "" ]]; then
|
||||
realpath "${FILE}" && exit 0
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
# **** Skim with Grep
|
||||
SkimGrep () {
|
||||
|
||||
|
||||
find . -type f \( -name "*.org" -o -name "*.md" \) |\
|
||||
sk --ansi -m -c 'rg -l -t markdown -t org -t txt --ignore-case "{}"' \
|
||||
--preview "bat --style snip {} 2> /dev/null \
|
||||
--color=always --line-range :500 \
|
||||
--terminal-width 80 \
|
||||
--theme=TwoDark |\
|
||||
rg --pretty --colors --context 20 {cq} \
|
||||
--no-line-number --ignore-case \
|
||||
--colors 'match:fg:21,39,200' \
|
||||
--colors 'line:style:nobold' \
|
||||
--colors 'match:style:bold' \
|
||||
--colors 'match:bg:30,200,30'" \
|
||||
--bind 'ctrl-f:interactive,pgup:preview-page-up,pgdn:preview-page-down' \
|
||||
--bind 'ctrl-w:execute-silent(echo {} |\
|
||||
xargs realpath |\
|
||||
xclip -selection clipboard)' \
|
||||
--bind 'alt-w:execute-silent(echo {} | xclip -selection clipboard)' \
|
||||
--bind 'alt-v:execute-silent(code -a {}),alt-e:execute-silent(emacs {})' \
|
||||
--bind 'ctrl-o:execute-silent(xdg-open {})' \
|
||||
--bind 'alt-y:execute-silent(cat {} | xclip -selection clipboard)' \
|
||||
--bind 'alt-o:execute-silent(cat {} |\
|
||||
pandoc -f markdown -t html --mathml |\
|
||||
xclip -selection clipboard)' \
|
||||
--bind 'alt-f:execute-silent(echo {} |\
|
||||
xargs dirname |\
|
||||
xargs cd; cat {} |\
|
||||
pandoc -f markdown -t dokuwiki --mathml |\
|
||||
xclip -selection clipboard)' \
|
||||
--color=fg:#f8f8f2,bg:-1,matched:#6272a4,current_fg:#50fa7b,current_bg:#381070,border:#ff79c6,prompt:#bd93f9,query:#bd93f9,marker:#f1fa8c,header:#f1fa8c
|
||||
|
||||
}
|
||||
|
||||
|
||||
# * Call Main Function
|
||||
main "${@}"
|
@@ -1,147 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
|
||||
# * Shell Settings
|
||||
set -o errexit # abort on nonzero exitstatus
|
||||
set -o nounset # abort on unbound variable
|
||||
set -o pipefail # don't hide errors within pipes
|
||||
|
||||
# * Main Function
|
||||
main() {
|
||||
|
||||
check_for_dependencies
|
||||
setVars
|
||||
readFirstArgument "${@}"
|
||||
NoteSearchRecoll "${@}"
|
||||
|
||||
}
|
||||
|
||||
# ** Helper Functions
|
||||
# *** Check for Dependencies
|
||||
check_for_dependencies () {
|
||||
|
||||
for i in ${DependArray[@]}; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** List of Dependencies
|
||||
|
||||
declare -a DependArray=(
|
||||
"bat"
|
||||
"sk"
|
||||
"recoll"
|
||||
"xclip"
|
||||
)
|
||||
|
||||
|
||||
# *** Set variables below main
|
||||
setVars () {
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
}
|
||||
|
||||
# **** Print Help
|
||||
Help () {
|
||||
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m ${script_name}\e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m--------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||
echo
|
||||
echo -e " "${script_name}" [<path/relative/Dir>]"
|
||||
echo -e " "${script_name}" [-h]"
|
||||
echo -e " "${script_name}" [--help]"
|
||||
echo
|
||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
||||
echo
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
||||
echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
||||
echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
||||
echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
||||
echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
||||
echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo
|
||||
echo -e " Often path names are too long to see in sk, "
|
||||
echo -e " although they do provide meaningful context,"
|
||||
echo -e " by displaying the pathnames relative from some directory"
|
||||
echo -e " this is somewhat addressed."
|
||||
echo -e " Absolute Paths are still returned for stability though."
|
||||
echo
|
||||
echo -e " Highlighting only works on the first word, I can't think of an easy"
|
||||
echo -e " way to convert a list of values ("dog" "fox" "jump") and then perform "
|
||||
echo -e " bat {} | rg -e dog -e fox -e jump " | highlight --syntax bash -O ansi
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||
echo
|
||||
echo -e " This uses realpath from GNU coreutils, which doesn't"
|
||||
echo -e " come with MacOS out of the box"
|
||||
echo
|
||||
echo -e " This doesn't work: "
|
||||
echo -e ' rg "$(echo {cq} | rg "$(echo $var | sed s+\ +\|+g )") ' | highlight --syntax bash -O ansi
|
||||
echo
|
||||
|
||||
}
|
||||
|
||||
|
||||
# *** Read First Argument
|
||||
readFirstArgument () {
|
||||
|
||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
||||
Help && exit 0
|
||||
fi
|
||||
|
||||
}
|
||||
# *** Note Recoll Search
|
||||
NoteSearchRecoll () {
|
||||
|
||||
## Change directory if One was specified, exit if no directory exists
|
||||
cd "${1}"
|
||||
|
||||
|
||||
## I really really like this one!!
|
||||
## Display Path Relative to Notes Dir
|
||||
# sk -i -c 'recoll -b -t -q "ext:md" {} | cut -c 8- | sd '^' 'realpath "' | sd '$' '" --relative-to "./"' | bash ' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
||||
# Better Theme
|
||||
RelativePath () {
|
||||
|
||||
find . -type f \( -name "*.org" -o -name "*.md" \) |\
|
||||
sk -m -i -c 'recoll -b -t -q "ext:md OR ext:org" {} |\
|
||||
cut -c 8- | sed s/^/realpath\ \"/ |\
|
||||
sed s+\$+\"\ --relative-to\ \"./\"+ | bash' \
|
||||
--bind pgup:preview-page-up,pgdn:preview-page-down \
|
||||
--preview "bat --style grid --color=always --line-range :500 \
|
||||
--terminal-width 80 --theme=TwoDark {+} \
|
||||
--italic-text=always \
|
||||
--decorations=always" \
|
||||
--color=fg:#f8f8f2,bg:-1,matched:#6272a4,current_fg:#50fa7b,current_bg:#381070,border:#ff79c6,prompt:#bd93f9,query:#bd93f9,marker:#f1fa8c,header:#f1fa8c
|
||||
}
|
||||
RELATIVE_PATH="$(RelativePath)"
|
||||
|
||||
echo "${RELATIVE_PATH}" | xargs realpath
|
||||
## ## Display full path
|
||||
## sk -i -c 'recoll -b -t -q "ext:md {}" | cut -c 8-' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
||||
##
|
||||
##
|
||||
## ## Display only file name
|
||||
## ##
|
||||
## sk -i -c 'recoll -b -t -q "ext:md" | cut -c 8- | sd \'^\' \'"\' | sd \'$\' \'"\' | sd \'^\' \'basename \' | bash' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "echo {} | xargs fd | xargs bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula "
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
# * Call Main Function
|
||||
main "${@}"
|
@@ -1,149 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
|
||||
# * Shell Settings
|
||||
set -o errexit # abort on nonzero exitstatus
|
||||
set -o nounset # abort on unbound variable
|
||||
set -o pipefail # don't hide errors within pipes
|
||||
|
||||
# * Main Function
|
||||
main() {
|
||||
|
||||
check_for_dependencies
|
||||
setVars
|
||||
readFirstArgument "${@}"
|
||||
NoteSearchRecoll "${@}"
|
||||
|
||||
}
|
||||
|
||||
# ** Helper Functions
|
||||
# *** Check for Dependencies
|
||||
check_for_dependencies () {
|
||||
|
||||
for i in ${DependArray[@]}; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** List of Dependencies
|
||||
|
||||
declare -a DependArray=(
|
||||
"bat"
|
||||
"sk"
|
||||
"recoll"
|
||||
"xclip"
|
||||
)
|
||||
|
||||
|
||||
# *** Set variables below main
|
||||
setVars () {
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
}
|
||||
|
||||
# **** Print Help
|
||||
Help () {
|
||||
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m ${script_name}\e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m--------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||
echo
|
||||
echo -e " "${script_name}" [<path/relative/Dir>]"
|
||||
echo -e " "${script_name}" [-h]"
|
||||
echo -e " "${script_name}" [--help]"
|
||||
echo
|
||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
||||
echo
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
||||
echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
||||
echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
||||
echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
||||
echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
||||
echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo
|
||||
echo -e " Often path names are too long to see in sk, "
|
||||
echo -e " although they do provide meaningful context,"
|
||||
echo -e " by displaying the pathnames relative from some directory"
|
||||
echo -e " this is somewhat addressed."
|
||||
echo -e " Absolute Paths are still returned for stability though."
|
||||
echo
|
||||
echo -e " Highlighting only works on the first word, I can't think of an easy"
|
||||
echo -e " way to convert a list of values ("dog" "fox" "jump") and then perform "
|
||||
echo -e " bat {} | rg -e dog -e fox -e jump " | highlight --syntax bash -O ansi
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||
echo
|
||||
echo -e " This uses realpath from GNU coreutils, which doesn't"
|
||||
echo -e " come with MacOS out of the box"
|
||||
echo
|
||||
echo -e " This doesn't work: "
|
||||
echo -e ' rg "$(echo {cq} | rg "$(echo $var | sed s+\ +\|+g )") ' | highlight --syntax bash -O ansi
|
||||
echo
|
||||
|
||||
}
|
||||
|
||||
|
||||
# *** Read First Argument
|
||||
readFirstArgument () {
|
||||
|
||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
||||
Help && exit 0
|
||||
fi
|
||||
|
||||
}
|
||||
# *** Note Recoll Search
|
||||
NoteSearchRecoll () {
|
||||
|
||||
## Change directory if One was specified, exit if no directory exists
|
||||
cd "${1}"
|
||||
|
||||
|
||||
## I really really like this one!!
|
||||
## Display Path Relative to Notes Dir
|
||||
# sk -i -c 'recoll -b -t -q "ext:md" {} | cut -c 8- | sd '^' 'realpath "' | sd '$' '" --relative-to "./"' | bash ' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
||||
# Better Theme
|
||||
RelativePath () {
|
||||
sk -m -i -c 'recoll -b -t -q "ext:md OR ext:org" {} |\
|
||||
cut -c 8- | sed s/^/realpath\ \"/ |\
|
||||
sed s+\$+\"\ --relative-to\ \"./\"+ | bash' \
|
||||
--bind pgup:preview-page-up,pgdn:preview-page-down \
|
||||
<<<<<<< HEAD
|
||||
--preview "bat --style grid --color=always --line-range :500 \
|
||||
--terminal-width 80 --theme=TwoDark {+} \
|
||||
--italic-text=always \
|
||||
--decorations=always" \
|
||||
=======
|
||||
--preview "mdcat {+}" \
|
||||
>>>>>>> ffa1640104ce9c097d1233a7d5745cd95fb9f7fb
|
||||
--color=fg:#f8f8f2,bg:-1,matched:#6272a4,current_fg:#50fa7b,current_bg:#381070,border:#ff79c6,prompt:#bd93f9,query:#bd93f9,marker:#f1fa8c,header:#f1fa8c
|
||||
}
|
||||
RELATIVE_PATH="$(RelativePath)"
|
||||
|
||||
echo "${RELATIVE_PATH}" | xargs realpath
|
||||
## ## Display full path
|
||||
## sk -i -c 'recoll -b -t -q "ext:md {}" | cut -c 8-' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
||||
##
|
||||
##
|
||||
## ## Display only file name
|
||||
## ##
|
||||
## sk -i -c 'recoll -b -t -q "ext:md" | cut -c 8- | sd \'^\' \'"\' | sd \'$\' \'"\' | sd \'^\' \'basename \' | bash' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "echo {} | xargs fd | xargs bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula "
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
# * Call Main Function
|
||||
main "${@}"
|
877
bin/cadmus
877
bin/cadmus
@@ -1,877 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
readonly script_name=$(basename "${0}")
|
||||
script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
readonly script_dir=$(realpath "${script_dir}""/""${script_name}" | xargs dirname)
|
||||
readonly CONFIG="$HOME/.config/cadmus/config.json" # one directory above
|
||||
## readonly SERVER_DIR="/srv/www/html/MD"
|
||||
## readonly RECOLL_CONFIG_DIR="$HOME/.cadmus"
|
||||
## readonly MKDOCS_YML="$HOME/Notes/mkdocs.yml" ## This may be above the notes directory, the
|
||||
## notes directory may not contain all the
|
||||
## images for want of seperation and mkdocs is
|
||||
## fidally, so specify the path to mkdocs.yml.
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
# abort on nonzero exitstatus
|
||||
set -o errexit
|
||||
# abort on unbound variable
|
||||
set -o nounset
|
||||
# don't hide errors within pipes
|
||||
set -o pipefail
|
||||
|
||||
# readonly EDITOR="ema"
|
||||
readonly EDITOR="xdg-open"
|
||||
|
||||
# * Main Functions
|
||||
|
||||
main() {
|
||||
checkConfig
|
||||
setvars
|
||||
[[ -z "${1:-}" ]] && mainHelp && exit 0
|
||||
arguments "${@:-}"
|
||||
}
|
||||
|
||||
function setvars() {
|
||||
|
||||
readonly TERMINAL="kitty"
|
||||
readonly TERMINAL_EXEC='kitty -- '
|
||||
|
||||
setClipboard
|
||||
|
||||
readonly NOTES_DIR="$(cat "${CONFIG}" | jq -r '.notesDir')"
|
||||
readonly SERVER_DIR="$(cat "${CONFIG}" | jq -r '.serverDir')"
|
||||
readonly RECOLL_CONFIG_DIR="$(cat "${CONFIG}" | jq -r '.recollConfigDir')"
|
||||
readonly MKDOCS_YML="$(cat "${CONFIG}" | jq -r '.mkdocsConfigDir')" ## This may be above the notes directory, the
|
||||
}
|
||||
|
||||
setClipboard () {
|
||||
|
||||
case "$(uname -s)" in
|
||||
|
||||
Darwin)
|
||||
CLIP_IN () { pbcopy ; }
|
||||
CLIP_OUT () { pbpaste ; }
|
||||
xdg-open () { open "%{@}" ; }
|
||||
;;
|
||||
|
||||
Linux|GNU|*BSD|SunOS)
|
||||
## "$XDG_SESSION_TYPE" not always defined
|
||||
if [[ "$( loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type | rg 'wayland' )" ]]; then
|
||||
CLIP_IN () { wl-copy ; }
|
||||
CLIP_OUT () { wl-paste ; }
|
||||
else
|
||||
CLIP_IN () { xclip -selection clipboard ; }
|
||||
CLIP_OUT () { xclip -selection clipboard -o ; }
|
||||
fi
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
CLIP_IN () { xclip -selection clipboard ; }
|
||||
CLIP_OUT () { xclip -selection clipboard -o ; }
|
||||
;;
|
||||
|
||||
# Add here more strings to compare
|
||||
# See correspondence table at the bottom of this answer
|
||||
|
||||
*)
|
||||
echo "Could not Detect OS, if you're not on Mac/Linux, file a bug please"
|
||||
echo "Applying Linux Defaults"
|
||||
CLIP_IN () { xclip -selection clipboard ; }
|
||||
CLIP_OUT () { xclip -selection clipboard -o ; }
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# * Sub-functions
|
||||
# ** MainMenu
|
||||
|
||||
function mainHelp() {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus\e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " 🔍 \e[1;93m \e[4mf\e[0m\e[1;93mind \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
||||
echo -e " 🔎 \e[1;32m \e[4ms\e[0m\e[1;32mearch \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Search through Notes using Recoll"
|
||||
echo -e " 🏷 \e[1;33m \e[4mt\e[0m\e[1;33mags \e[0m \e[1;34m ┊┊┊ 📁\e[0m Use TMSU to work with tags"
|
||||
echo -e " 📖 \e[1;33m \e[4mr\e[0m\e[1;33mofi \e[0m \e[1;34m ┊┊┊ 📁\e[0m Use ROFI instead of fzf (WIP) "
|
||||
echo -e " 🔧 \e[1;34m \e[4mto\e[0m\e[1;34mols \e[0m \e[1;34m ┊┊┊ 📁\e[0m Tools for Editing"
|
||||
echo -e " 📝 \e[1;35m \e[4me\e[0m\e[1;35mxport \e[0m \e[1;34m ┊┊┊ 📁\e[0m Export Notes to Different Formats "
|
||||
echo -e " ⎋ \e[1;36m \e[4mc\e[0m\e[1;36monvert \e[0m \e[1;34m ┊┊┊ 📁\e[0m Convert Clipboard Contents to Different Formats "
|
||||
echo -e " 🧰 \e[1;37m \e[4mm\e[0m\e[1;37misc \e[0m \e[1;34m ┊┊┊ 📁\e[0m Miscelanneous Tools nice to have on hand "
|
||||
echo -e " 🌏 \e[1;92m \e[4mpub\e[0m\e[1;92mlish\e[0m \e[1;34m ┊┊┊ 📁\e[0m Publish with \e[1;34m \e[4m\e[3mMkDocs\e[0m\e[0m🐍"
|
||||
echo -e " 🕮 \e[1;93m \e[4mp\e[0m\e[1;93mreview \e[0m \e[1;34m ┊┊┊ 🎆\e[0m Preview with \e[1;34m \e[4m\e[3mMarkServ\e[0m\e[0m (use 'preview!' for global)"
|
||||
echo -e " 🕮 \e[1;94m \e[4mh\e[0m\e[1;94melp \e[0m \e[1;34m ┊┊┊ 🎆\e[0m Open help for correspoding functions "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Legend\e[0m "
|
||||
echo
|
||||
echo -e " 🎆: Executes a command, a Suffixed -h argument will print help"
|
||||
echo -e " 📁: Prints another Menu"
|
||||
echo
|
||||
}
|
||||
|
||||
# ** Main Arguments - Level 0
|
||||
# *** Config
|
||||
checkConfig () {
|
||||
if [[ -f "${CONFIG}" ]]; then
|
||||
echo "Config Detected"
|
||||
else
|
||||
echo -e "No config File detected at ${CONFIG}"
|
||||
echo -e "Would you like to generate a config?"
|
||||
echo
|
||||
echo -e "Press y to continue or any other key to exit."
|
||||
echo
|
||||
read -d '' -s -n1 choice
|
||||
if [[ "${choice}" == "y" ]]; then
|
||||
config_json=$("${script_dir}/makeConfig.bash")
|
||||
if [[ "${config_json}" != "" ]]; then
|
||||
[[ -d "$(dirname "${CONFIG}")" ]] || mkdir -p "$(dirname "${CONFIG}")"
|
||||
echo "${config_json}" > "${CONFIG}"
|
||||
echo -e "This is the Config:\n"
|
||||
highlight "${CONFIG}"
|
||||
else
|
||||
echo "Config not Generated"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
# *** Switch
|
||||
arguments () {
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
--help|-h) mainHelp && exit 0
|
||||
;;
|
||||
find|f) shift; NoteFind "${NOTES_DIR}" "${@:-}" ## Don't steal function name
|
||||
;;
|
||||
search|s) shift; NoteSearch "${NOTES_DIR}" ${@:-}
|
||||
;;
|
||||
rofi|r) shift; RofiMenu ${@:-}
|
||||
;;
|
||||
tags|t) shift; CadmusTags ${@:-}
|
||||
;;
|
||||
tools|to) shift; CadmusTools "${@:-}"
|
||||
;;
|
||||
export|e) shift; CadmusExport "${@:-}"
|
||||
;;
|
||||
convert|c) shift; CadmusConvert "${@:-}"
|
||||
;;
|
||||
misc|m) shift; CadmusMisc "${@:-}"
|
||||
;;
|
||||
publish|pub) shift; CadmusPublish "${@:-}"
|
||||
;;
|
||||
preview|p) shift; cd "${NOTES_DIR}" && markserv || echo -e " \n \e[1;34m maybe fix this with:\n\tsudo fuser 35729/tcp -k \n \tor\n\tkillall markserv \e[0m\n"
|
||||
;;
|
||||
preview!) shift; previewGlobal
|
||||
;;
|
||||
help|h) subHelp && exit 0
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
# *** Find
|
||||
function NoteFind() {
|
||||
COMMAND="${script_dir}/NoteFind.sh"
|
||||
echo "Running "${COMMAND}" "${1}""
|
||||
|
||||
FILES="$("${COMMAND}" "${@:-}")"
|
||||
|
||||
## Only try and open something that is non-empty
|
||||
if [ "$FILES" != "" ]; then
|
||||
## xdg-open doesn't accept multiple arguments, so create commands and
|
||||
## pipe them back into bash This opens all files in the same tab with
|
||||
## VSCode and Atom The individual selections can also be passed off with
|
||||
## the keybindings to emacsclient.
|
||||
# Using XDG-OPEN
|
||||
# echo "${FILES}" | sed s/^/xdg-open\ \"/ | sed s/$/\"/ | bash
|
||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
||||
|
||||
# # Getting the .desktop file and cutting off the Extension
|
||||
# dex "$(xdg-mime query default text/markdown)" $FILES
|
||||
# dex "$(xdg-mime query default text/markdown)" $FILES
|
||||
## This might break if the .desktop file doesn't have the same
|
||||
## name as the binary.
|
||||
## This appears to be a standard though
|
||||
## https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#file-naming
|
||||
fi
|
||||
}
|
||||
|
||||
# *** Search
|
||||
function NoteSearch() {
|
||||
COMMAND="${script_dir}/NoteRecollSearch.sh"
|
||||
echo "Running "${COMMAND}" "${1}""
|
||||
|
||||
FILES="$("${COMMAND}" "${@:-}")"
|
||||
|
||||
## Only try and open something that is non-empty
|
||||
if [ "$FILES" != "" ]; then
|
||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# *** RofiMenu
|
||||
function RofiMenu() {
|
||||
|
||||
[[ -z "${1:-}" ]] && RofiHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
search) shift; "${script_dir}"/rofi_search.sh "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
find) shift; "${script_dir}"/rofi_find.sh "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Rofi Help
|
||||
function RofiHelp() {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Rofi\e[0m; Use Rofi and Browser to Search/Find and Preview"
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;93m find \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
||||
echo -e " \e[1;32m search \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Create Tags with TMSU"
|
||||
echo
|
||||
}
|
||||
|
||||
# *** Note Search
|
||||
|
||||
function NoteSearch() {
|
||||
COMMAND="${script_dir}/NoteRecollSearch.sh"
|
||||
echo "Running "${COMMAND}" "${1}""
|
||||
|
||||
FILES="$("${COMMAND}" "${@:-}")"
|
||||
|
||||
## Only try and open something that is non-empty
|
||||
if [ "$FILES" != "" ]; then
|
||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# *** Tags
|
||||
CadmusTags () {
|
||||
[[ -z "${1:-}" ]] && TagsHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
filter) shift; "${script_dir}/tags/FilterNotesByTMSUTag.sh" "${NOTES_DIR}" "${@:-}"
|
||||
;;
|
||||
create) shift; "${script_dir}/tags/tags-to-TMSU.sh" "${NOTES_DIR}" ${@:-} && exit 0
|
||||
;;
|
||||
mount) shift; MountTags
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Mount Tags
|
||||
MountTags () {
|
||||
cd "${NOTES_DIR}"
|
||||
|
||||
DIR="$(mktemp -d)"
|
||||
|
||||
tmsu mount "${DIR}"
|
||||
nautilus "${DIR}" && exit 0
|
||||
}
|
||||
|
||||
|
||||
# **** Help
|
||||
function TagsHelp() {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Tags\e[0m; Filter and Create TMSU Tags"
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo
|
||||
echo -e " Tags are very much so a work in progress, the relevant scripts are:"
|
||||
echo -e " • FilterNotesByTMSUTag.sh "
|
||||
echo -e " • tags-to-TMSU.sh "
|
||||
echo
|
||||
echo -e " There very much an assumption that there is a .tmsu folder "
|
||||
echo -e " somewhere above the NOTES_DIR "
|
||||
echo -e " (in this case that is "${NOTES_DIR}")"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Troubleshooting\e[0m \n"
|
||||
echo -e " If you are having Issues use the following to find any .tmsu databases:"
|
||||
echo -e ' find $HOME -type d -name '.tmsu'' | highlight --syntax bash -O ansi
|
||||
echo -e " And delete all the databases to start fresh\n"
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;93m filter \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
||||
echo -e " \e[1;32m create \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Create Tags with TMSU"
|
||||
echo -e " \e[1;32m mount \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Mount Tags as a Virtual FS"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** Tools
|
||||
CadmusTools () {
|
||||
[[ -z "${1:-}" ]] && ToolsHelp && exit 0
|
||||
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
new) shift; makeNewNote "${@}" && exit 0
|
||||
;;
|
||||
webtitle) shift; "${script_dir}/tools/PrintWebTitle.sh" "$(CLIP_OUT)" | CLIP_IN
|
||||
;;
|
||||
backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "$(CLIP_OUT)" "${NOTES_DIR}" ${@:-} && exit 0
|
||||
;;
|
||||
link) shift; "${script_dir}/tools/LinkMarkdownNotes.sh" "${NOTES_DIR}" "$(CLIP_OUT)" | CLIP_IN && exit 0
|
||||
;;
|
||||
fix) shift; "${script_dir}/tools/fixLink.sh" "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
|
||||
unused-attachments) shift; node "${script_dir}/tools/print_unused_attachments.js" "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
||||
;;
|
||||
random) shift; find "${NOTES_DIR}" -name '*.md' | shuf -n 1 | xargs "${EDITOR}" && exit 0
|
||||
;;
|
||||
rename) shift; CadmusRename "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Help
|
||||
function ToolsHelp() {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Tools\e[0m; Tools for Editing Notes "
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Legend\e[0m "
|
||||
echo -e " ✀ Works with the clipboard for input/output."
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo -e " Renaming relies on the assumption that all notes have unique names."
|
||||
echo -e " If two notes have the same name consider giving one a more descriptive name"
|
||||
echo -e " or merging them."
|
||||
echo
|
||||
echo -e " To fix the links this just uses a dumb call to sed, this shouldn't be an issue"
|
||||
echo -e " if file names are unique-long-and-descriptive-without-whitespace.md, unless"
|
||||
echo -e " ∵ I doubt you would use a slugified word like that for any other reason in a note"
|
||||
echo -e " \tNone the less commit changes before renaming and then use the diff after"
|
||||
echo -e " \tto see which changes you want to commit in the event there are false positives"
|
||||
echo
|
||||
echo -e " When Using Rename, make sure to not type in the extension, this is automatically"
|
||||
echo -e " Done so that the same logic could be used on org-files"
|
||||
echo
|
||||
echo -e " For the sake of Sanity (my sanity) Renaming will not work with the following characters:"
|
||||
echo -e " . ...................................(period)"
|
||||
echo -e " ␣ ...................................(i.e. whitespace)"
|
||||
echo -e " / ...................................(forward slash)"
|
||||
echo -e " \\ ..................................(back slash)"
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m ┊┊┊ \e[0m Description "
|
||||
echo -e " ..................\e[1;34m....┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;93m new \e[0m \e[1;34m ┊┊┊ \e[0m Starts an interactive prompt to make a new note"
|
||||
echo -e " \e[1;93m webtitle \e[0m \e[1;34m ┊┊┊ \e[0m✀ Transforms the Clipboard 📋 to a Link"
|
||||
echo -e " \e[1;93m backlinks \e[0m \e[1;34m ┊┊┊ \e[0m✀ Takes the Abs Path of a Note from the Clipboard 📋"
|
||||
echo -e " \e[1;93m \e[0m \e[1;34m ┊┊┊ \e[0m and prints out backlinks (Abs Path)"
|
||||
echo -e " \e[1;93m fix \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Fix the relative path in the clipboard 📋 "
|
||||
echo -e " \e[1;93m unused-attachments \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Print unused attachments, not working yet "
|
||||
echo -e " \e[1;93m link \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Generate a link to another note from the current in the clipboard"
|
||||
echo -e " \e[1;32m page-import \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Transform Clipboard from URL to corresponding Markdown"
|
||||
echo -e " \e[1;32m random \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Open a Random Note in the Default program"
|
||||
echo -e " \e[1;32m rename \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Choose a note to rename and adjust all links"
|
||||
echo
|
||||
}
|
||||
|
||||
# **** New Note
|
||||
|
||||
makeNewNote () {
|
||||
echo -e "Please Choose Relevant Tags (Use Tab for Multi Select)"
|
||||
echo -e "\n\t(Press any key to continue)"
|
||||
read -d '' -s -n1 choice
|
||||
|
||||
## Choose Tags
|
||||
TAGS="$(node "${script_dir}"/tags/yaml-parse.js "${NOTES_DIR}" 2>/dev/null | sort -u| sk -m)"
|
||||
|
||||
if [[ "${TAGS}" != "" ]]; then
|
||||
TAGS="$(echo "${TAGS}" | sed 's/^\|$//g'|paste -sd, - | sed 's/,/,\ /g' | sed 's/^/\[/' | sed 's/$/\]/')"
|
||||
fi
|
||||
|
||||
echo "${TAGS}"
|
||||
|
||||
echo -e "\nPlease Choose an appropriate directory\n\n"
|
||||
echo -e "\n\t(Press any key to continue)"
|
||||
read -d '' -s -n1 choice
|
||||
|
||||
## Chose Directory
|
||||
DIR="$(find "${NOTES_DIR}" -type d | sk)" || exit 0
|
||||
|
||||
## Enter a name
|
||||
echo -e "Please enter a title for the note:\n"
|
||||
read NAME
|
||||
|
||||
## Name must be non-empty
|
||||
if [[ "${NAME}" != "" ]]; then
|
||||
NAME_SLUG="$(echo "${NAME}" | sed s/\ /-/g )"
|
||||
else
|
||||
echo "No input for title, aborting" && exit 0
|
||||
fi
|
||||
|
||||
## combine dir and name to get path
|
||||
FILE="${DIR}/${NAME_SLUG}.md"
|
||||
echo -e "Creating:\n "${FILE}""
|
||||
|
||||
## Test for the file
|
||||
if [ -f "${DIR}/${NAME_SLUG}.md" ]; then
|
||||
echo "${DIR}/${NAME_SLUG}.md" | CLIP_IN
|
||||
echo "The file exists, aborting"
|
||||
echo "The desired path is in the clipboard" && exit 0
|
||||
else
|
||||
touch "${DIR}/${NAME_SLUG}.md"
|
||||
fi
|
||||
|
||||
## Get time and date
|
||||
printf -v date '%(%Y-%m-%dT%H:%M:%S)T\n' -1
|
||||
date="$(echo ${date} | sed s/^/\'/ | sed s/$/\'/)"
|
||||
|
||||
## Create the new file
|
||||
echo -e "---" >> "${FILE}"
|
||||
echo -e "title: "${NAME}"" >> "${FILE}"
|
||||
echo -e "tags: "${TAGS}"" >> "${FILE}"
|
||||
echo -e "created: "${date}"" >> "${FILE}"
|
||||
echo -e "---\n" >> "${FILE}"
|
||||
echo -e "# "${NAME}"" >> "${FILE}"
|
||||
|
||||
mdcat "${FILE}"
|
||||
echo -e "Succesfully Created:\n "${FILE}""
|
||||
nvim + "${FILE}"
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** Rename
|
||||
CadmusRename () {
|
||||
COMMAND="${script_dir}/NoteFind.sh"
|
||||
echo "Running "${COMMAND}" "${1}""
|
||||
|
||||
FILES="$("${COMMAND}" "${@:-}")"
|
||||
|
||||
for i in $FILES; do
|
||||
DirofNote="$(dirname "${i}")"
|
||||
getnames "${1}"
|
||||
echo -e "\n Renaming \e[1;32m"${OLDNAME}"\e[0m to \e[1;32m"${NEWNAME}"\e[0m\n"
|
||||
renameThenSed "${i}" "${OLDNAME}" "${NEWNAME}"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# ***** Prompt for Names
|
||||
#
|
||||
getnames () {
|
||||
OLDNAME="$(basename $i | cut -f 1 -d '.' )"
|
||||
EXTENSION="$(basename $i | rev | cut -f 1 -d '.' | rev )"
|
||||
echo -e "\nplease enter a new name \e[1;31mWITHOUT THE .md \e[0m\n for:\n \e[1;34m"${OLDNAME}"\e[0m\n"
|
||||
read NEWNAME && [[ "${NEWNAME}" == "" ]] && echo -e "\e[1;31mRequire a New Name!\e[0m" && getnames "${i}"
|
||||
|
||||
## Remove whitespace from new name
|
||||
NEWNAME="$(echo "${NEWNAME}" | sed s/\ /-/g)"
|
||||
}
|
||||
# ***** Rename then Sed
|
||||
renameThenSed () {
|
||||
## Rename
|
||||
echo "${DirofNote}"
|
||||
echo "mv "\'${DirofNote}/${OLDNAME}.md\'" "\'${DirofNote}/${NEWNAME}\'" "
|
||||
echo "mv "\'${DirofNote}/${OLDNAME}.md\'" "\'${DirofNote}/${NEWNAME}.md\'" " | bash
|
||||
|
||||
## Sed
|
||||
echo "sd -s "\'${OLDNAME}\'" "\'${NEWNAME}\'""
|
||||
sd -s "${OLDNAME}" "${NEWNAME}" $(fd --type file '.md' "$NOTES_DIR")
|
||||
}
|
||||
# *** Export
|
||||
CadmusExport () {
|
||||
[[ -z "${1:-}" ]] && ExportHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
odt) shift; pandocExport odt && exit 0
|
||||
;;
|
||||
docx) shift; pandocExport docx && exit 0
|
||||
;;
|
||||
org) shift; pandocExport org && exit 0
|
||||
;;
|
||||
md) shift; pandocExport md && exit 0
|
||||
;;
|
||||
pdf) shift; pandocExport pdf --pdf-engine=xelatex && exit 0
|
||||
;;
|
||||
tex) shift; pandocExport tex && exit 0
|
||||
;;
|
||||
tectonic) shift; pandocExport pdf --pdf-engine=tectonic && exit 0
|
||||
;;
|
||||
weasyprint) shift; pandocExport pdf --pdf-engine=weasyprint && exit 0
|
||||
;;
|
||||
html) shift; pandocExport html --mathml --self-contained -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
||||
;;
|
||||
html-dir) shift; pandocExport html --mathjax -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
||||
;;
|
||||
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Pandoc Export
|
||||
pandocExport () { # $1 is extension; $2+ are options for pandoc
|
||||
echo "If the file path is in the clipboard press y to continue"
|
||||
echo " Press any key to choose a note to export"
|
||||
read -d '' -s -n1 pathInClipQ
|
||||
if [ "$pathInClipQ" == "y" ]; then
|
||||
FILEPATH="$(CLIP_OUT)"
|
||||
else
|
||||
FILEPATH=$("${script_dir}/NoteFind.sh" "${NOTES_DIR}")
|
||||
fi
|
||||
[[ -f "${FILEPATH}" ]] && FILE="$(basename ${FILEPATH})" || exit 0
|
||||
FILEOUT="$(echo ${FILE} | cut -f 1 -d '.').${1}"
|
||||
shift
|
||||
cd "$(echo "${FILEPATH}" | xargs realpath | xargs dirname)"
|
||||
OUTDIR="$(mktemp -d /tmp/cadmusExportXXX)"
|
||||
|
||||
echo
|
||||
echo -e " \e[1;94m Calling pandoc from: \e[1;32m $(pwd) \e[0m"
|
||||
echo -e " \e[1;94m Output to: \e[1;32m "${OUTDIR}"/"${FILEOUT}"\e[0m"
|
||||
echo
|
||||
echo -e " \e[1;94m Performing: \e[0m"
|
||||
echo " pandoc -s "${FILE}" --mathjax ${@:-} --extract-media="${OUTDIR}/Media" -o "${OUTDIR}"/"${FILEOUT} | highlight --syntax bash -O ansi
|
||||
echo
|
||||
|
||||
## Media must have first letter capitalised for mediawiki
|
||||
## HTML2Wiki wants zip file
|
||||
|
||||
pandoc -s "${FILE}" ${@:-} --extract-media="${OUTDIR}/Media" -o "${OUTDIR}"/"${FILEOUT}" || exit 7
|
||||
cd "${OUTDIR}"
|
||||
## Run it a second time so extracted media is relative not absolute
|
||||
## It seems mathjax only works here, not katex :shrug:
|
||||
pandoc -f -s --mathjax "${FILEOUT}" ${@:-} --extract-media="Media" -o "${FILEOUT}" || echo "" # This might fail for PDF's, don't exit
|
||||
## Zip everything up as well
|
||||
zip -r "$(echo ${FILE} | cut -f 1 -d '.')".zip *
|
||||
"${EDITOR}" "${OUTDIR}"/"${FILEOUT}"
|
||||
cd -
|
||||
}
|
||||
|
||||
# **** Help
|
||||
function ExportHelp () {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Export\e[0m; Tools for Editing Notes "
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo -e " This does not work for multiple selections (yet) so avoid pressing"
|
||||
echo -e " TAB to try and export multiple files, it won't work"
|
||||
echo
|
||||
echo -e " The links in exports are made relative, by using a second call to pandoc"
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ...............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;32m odt \e[0m \e[1;34m ┊┊┊ \e[0mExport a Note to ODT (no syntax highlighting)"
|
||||
echo -e " \e[1;32m docx \e[0m \e[1;34m ┊┊┊ \e[0mExport a Note to .docx"
|
||||
echo -e " \e[1;32m pdf \e[0m \e[1;34m ┊┊┊\e[0m Export a Note to PDF with LaTeX"
|
||||
echo -e " \e[1;32m tex \e[0m \e[1;34m ┊┊┊\e[0m Export a Note to LaTeX"
|
||||
echo -e " \e[1;32m tectonic \e[0m \e[1;34m ┊┊┊\e[0m Export with Tectonic (Slow)"
|
||||
echo -e " \e[1;32m weasyprint \e[0m \e[1;34m ┊┊┊\e[0m Make a PDF that looks like HTML"
|
||||
echo -e " \e[1;32m html \e[0m \e[1;34m ┊┊┊\e[0m Make a self-contained MathML HTML (firefox/safari only)"
|
||||
echo -e " \e[1;32m html-dir \e[0m \e[1;34m ┊┊┊\e[0m Make a directory of HTML+images (for importing to Mediawiki)"
|
||||
echo -e " \e[1;32m md \e[0m \e[1;34m ┊┊┊\e[0m Export markdown and images to directory"
|
||||
echo -e " \e[1;32m org \e[0m \e[1;34m ┊┊┊\e[0m Export as org-mode with images to directory"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** Convert
|
||||
CadmusConvert () {
|
||||
[[ -z "${1:-}" ]] && ConvertHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
org2md) shift; CLIP_OUT | pandoc -f org -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit
|
||||
;;
|
||||
md2org) shift; CLIP_OUT | pandoc -f markdown_github+tex_math_dollars --atx-headers -t org | CLIP_IN && exit
|
||||
;;
|
||||
tex2md) shift; CLIP_OUT | pandoc -f latex -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit
|
||||
;;
|
||||
md2tex) shift; CLIP_OUT | pandoc -f markdown_github+tex_math_dollars --atx-headers -t latex | CLIP_IN && exit
|
||||
;;
|
||||
html2md) shift; CLIP_OUT | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit
|
||||
;;
|
||||
md2html) shift; CLIP_OUT | pandoc -f markdown_github+tex_math_dollars --atx-headers -t html | CLIP_IN && exit
|
||||
;;
|
||||
mediawiki2md) shift; CLIP_OUT | pandoc -f mediawiki -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit
|
||||
;;
|
||||
md2mediawiki) shift; CLIP_OUT | pandoc -f markdown_github+tex_math_dollars --atx-headers -t mediawiki | CLIP_IN && exit
|
||||
;;
|
||||
dokuwiki2md) shift; CLIP_OUT | pandoc -f dokuwiki -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit
|
||||
;;
|
||||
md2dokuwiki) shift; CLIP_OUT | pandoc -f markdown_github+tex_math_dollars --atx-headers -t dokuwiki | CLIP_IN && exit
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# *** Preview Global
|
||||
previewGlobal() {
|
||||
MARKSERVPORT="28754"
|
||||
cd "${NOTES_DIR}"
|
||||
printQR
|
||||
markserv -p "${MARKSERVPORT}" -a 0.0.0.0 || echo -e " \n \e[1;34m maybe fix this with:\n\tsudo fuser 35729/tcp -k \n \tor\n\tkillall markserv \e[0m\n"
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** Print QR
|
||||
printQR () {
|
||||
command -v qrencode >/dev/null 2>&1 || { echo -e >&2 "I require qrencode but it's not installed.\nNo QR Code can be printed."; return; }
|
||||
command -v ip >/dev/null 2>&1 || { echo -e >&2 "I requre ip but it's not installed.\nNo QR Code can be printed."; return; }
|
||||
|
||||
CURRENTIP="$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')"
|
||||
qrencode -t UTF8 "http://${CURRENTIP}:${MARKSERVPORT}"
|
||||
|
||||
}
|
||||
|
||||
# **** Help
|
||||
function ConvertHelp () {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Convert\e[0m; Convert the Clipboard in place"
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo -e " These commands all transform the clipboard in place."
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;32m org2md \e[0m \e[1;34m ┊┊┊ \e[0m Transform org-mode to \e[3mMarkDown\e[0m"
|
||||
echo -e " \e[1;32m md2org \e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mMarkDown\e[0m to org-mode"
|
||||
echo -e " ……… \e[0m\e[1;34m┊┊┊\e[0m"
|
||||
echo -e " \e[1;32m tex2md \e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mLaTeX\e[0m to \e[3mMarkDown\e[0m"
|
||||
echo -e " \e[1;32m md2tex \e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mMarkDown\e[0m to \e[3mLaTeX\e[0m"
|
||||
echo -e " ……… \e[0m\e[1;34m┊┊┊\e[0m"
|
||||
echo -e " \e[1;32m html2md\e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mHTML\e[0m to \e[3mMarkDown\e[0m"
|
||||
echo -e " \e[1;32m html2org \e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mMarkDown\e[0m to \e[3mHTML\e[0m"
|
||||
echo -e " ……… \e[0m\e[1;34m┊┊┊\e[0m"
|
||||
echo -e " \e[1;32m mediawiki2md\e[0m \e[1;34m┊┊┊ \e[0m Transform \e[3mMediaWiki\e[0m to \e[3mMarkDown\e[0m"
|
||||
echo -e " \e[1;32m md2mediawiki\e[0m \e[1;34m┊┊┊ \e[0m Transform \e[3mMarkDown\e[0m to \e[3mMediaWiki\e[0m"
|
||||
echo -e " ……… \e[0m\e[1;34m┊┊┊\e[0m"
|
||||
echo -e " \e[1;32m dokuwiki2md\e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mDokuwiki\e[0m to \e[3mMarkDown\e[0m"
|
||||
echo -e " \e[1;32m md2dokuwiki\e[0m \e[1;34m ┊┊┊ \e[0m Transform \e[3mMarkDown\e[0m to \e[3mDokuwiki\e[0m"
|
||||
echo -e " ……… \e[0m\e[1;34m┊┊┊\e[0m"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** Misc
|
||||
CadmusMisc() {
|
||||
[[ -z "${1:-}" ]] && MiscHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
ranger) shift; ranger "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
code) shift; code "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
atom) shift; atom "${NOTES_DIR}" && exit 0
|
||||
;;
|
||||
wa) shift; wmctrl -a "$(wmctrl -l | cut -f 5- -d " " | fzf)" && exit 0
|
||||
;;
|
||||
wR) shift; wmctrl -R "$(wmctrl -l | cut -f 5- -d " " | fzf)" && exit 0
|
||||
;;
|
||||
print) shift; "${script_dir}/NoteFind.sh" "${NOTES_DIR}" | xargs mdcat
|
||||
;;
|
||||
sync) shift; cd "${NOTES_DIR}"; git pull && git add -A && git commit && git push
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Help
|
||||
function MiscHelp () {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Export\e[0m; Tools for Editing Notes "
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[1;91m\e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..........\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;32m ranger \e[0m \e[1;34m ┊┊┊ \e[0m Open Notes Directory in Ranger"
|
||||
echo -e " \e[1;32m code \e[0m \e[1;34m ┊┊┊ \e[0m Open Notes Directory in Ranger"
|
||||
echo -e " \e[1;32m atom \e[0m \e[1;34m ┊┊┊ \e[0m Open Notes Directory in Ranger"
|
||||
echo -e " \e[1;32m wa \e[0m \e[1;34m ┊┊┊ \e[0m Activate Window FIX: use command not alias?"
|
||||
echo -e " \e[1;32m wR \e[0m \e[1;34m ┊┊┊ \e[0m Relocate Window (Like rofi)"
|
||||
echo -e " \e[1;32m print \e[0m \e[1;34m ┊┊┊ \e[0m Print Markdown to the terminal (with images)"
|
||||
echo -e " \e[1;32m sync \e[0m \e[1;34m ┊┊┊ \e[0m pull, add -A, commit and push repository"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo -e " "
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** Publish
|
||||
CadmusPublish () {
|
||||
[[ -z "${1:-}" ]] && PublishHelp && exit 0
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
gh-deploy) shift; [[ -f "${MKDOCS_YML}" ]] && cd "$(dirname $(realpath ${MKDOCS_YML}))" && mkdocs gh-deploy || echo "Cannot locate "${MKDOCS_YML}""
|
||||
;;
|
||||
server) shift; [[ -f "${MKDOCS_YML}" ]] && cd "$(dirname $(realpath ${MKDOCS_YML}))" && mkdocs --clean --site-dir "${SERVER_DIR}" || echo "Cannot locate "${MKDOCS_YML}""
|
||||
;;
|
||||
--*) >&2 echo "bad option $1"
|
||||
;;
|
||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# **** Help
|
||||
function PublishHelp () {
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1m Cadmus Export\e[0m; Tools for Editing Notes "
|
||||
echo -e " \e[1;31m -------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
||||
echo -e " Building in server directory will require root priviliges"
|
||||
echo
|
||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
echo -e " \e[1;32m gh-deploy \e[0m \e[1;34m ┊┊┊ \e[0m call mkdocs gh-deploy from ${NOTES_DIR} "
|
||||
echo -e " \e[1;32m server \e[0m \e[1;34m ┊┊┊ \e[0m Build Mkdocs in ${SERVER_DIR}"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# *** All the Help
|
||||
## I think all the help files should just be md files, then I could simply do `mdcat *`
|
||||
subHelp () {
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Find \e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
"${script_dir}/NoteFind.sh"
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Search\e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
"${script_dir}/NoteRecollSearch.sh"
|
||||
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Tools\e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
ToolsHelp # This is the exception because these things don't have a help cause they're so simple
|
||||
|
||||
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Export \e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
ExportHelp
|
||||
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Convert \e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
ConvertHelp
|
||||
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Misc \e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
MiscHelp
|
||||
|
||||
|
||||
echo
|
||||
echo
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " \e[1;94m\e[3m\e[1m Preview \e[0m"
|
||||
echo -e "\e[1;35m -------------------------\e[0m "
|
||||
echo -e " this should just work"
|
||||
}
|
||||
|
||||
# * Call the Main Function
|
||||
main "${@}"
|
194
bin/main.go
Executable file
194
bin/main.go
Executable file
@@ -0,0 +1,194 @@
|
||||
package main
|
||||
|
||||
// TODO command line argument to re-index? that would be quicker
|
||||
// TODO just return the name of matches
|
||||
// TODO I need to evaluate how long tantivy takes to index, Ideally I want to index on the fly, I need to see if that's an option
|
||||
// i.e. an option if I had 100 times the notes I had, so the time taken would need to be 2 ms when this is 10, I doubt rust will
|
||||
// bring that sort of a performance gain, but I should see none the less.
|
||||
// NOTE Tantivy said it took 2000 docs per sec from the JSON, currently this does 70 docs/sec
|
||||
// this should help
|
||||
// https://tantivy-search.github.io/examples/basic_search.html
|
||||
// TODO Can I map this over multiple cores? Indexing would be much faster in that case it looks like it's already working over many cores though.
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/blevesearch/bleve/v2"
|
||||
"github.com/schollz/progressbar/v3"
|
||||
)
|
||||
|
||||
type text_structure struct {
|
||||
Path string
|
||||
Content string
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
files := listFiles()
|
||||
|
||||
index_path := "example.bleve"
|
||||
|
||||
// delete_index(index_path)
|
||||
index := Make_index(index_path, files)
|
||||
|
||||
do_search(index)
|
||||
|
||||
}
|
||||
|
||||
func do_search(index bleve.Index) {
|
||||
|
||||
// search for some text
|
||||
// TODO Make this an interactive query
|
||||
query_text := getInput()
|
||||
query := bleve.NewMatchQuery(query_text)
|
||||
search := bleve.NewSearchRequest(query)
|
||||
searchResults, err := index.Search(search)
|
||||
if err != nil {
|
||||
|
||||
fmt.Println("No Search Results :( ")
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Print out the Results
|
||||
// TODO Only print out the File Path
|
||||
// TODO, give this file path to fuzzy-finder-go --preview
|
||||
fmt.Println(searchResults) // This prints everything
|
||||
// fmt.Println(searchResults.Hits[0].ID) // This prints the ID of the first
|
||||
|
||||
}
|
||||
|
||||
func getInput() string {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
fmt.Print("Enter a Search Term:\n")
|
||||
term, _ := reader.ReadString('\n')
|
||||
return term
|
||||
}
|
||||
|
||||
func Make_index(index_path string, files []string) bleve.Index {
|
||||
|
||||
// TODO This should have more error checking, what if there is just a write permission?
|
||||
// what if it's the wrong file? then it would be overwritten...
|
||||
index, err := bleve.Open(index_path)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Println("Creating a New index")
|
||||
mapping := bleve.NewIndexMapping()
|
||||
index, err = bleve.New(index_path, mapping)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
fmt.Print("Unable to Create new index")
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Appending to Old Index")
|
||||
}
|
||||
|
||||
notecontent := getFile("/home/ryan/Sync/Notes/Org/1.org")
|
||||
data3 := text_structure{
|
||||
Path: "1.org",
|
||||
Content: notecontent,
|
||||
}
|
||||
_ = data3
|
||||
|
||||
bar := progressbar.Default(int64(len(files)))
|
||||
documents := []text_structure{}
|
||||
i := 1
|
||||
|
||||
for _, file := range files {
|
||||
// fmt.Println(file)
|
||||
i = i + 1
|
||||
|
||||
notecontent = getFile(file)
|
||||
|
||||
data3 = text_structure{
|
||||
Path: file,
|
||||
Content: notecontent,
|
||||
}
|
||||
|
||||
// documents = append(documents, data3)
|
||||
// fmt.Println(file)
|
||||
|
||||
index.Index(data3.Path, data3)
|
||||
|
||||
bar.Add(1)
|
||||
|
||||
}
|
||||
|
||||
data1 := text_structure{
|
||||
Path: "/home/ryan/Notes/MD/index.md",
|
||||
Content: "lots of text in quick brown fox",
|
||||
}
|
||||
|
||||
data2 := text_structure{
|
||||
Path: "1.org",
|
||||
Content: notecontent,
|
||||
}
|
||||
// TODO loop over files
|
||||
|
||||
documents = append(documents, data1)
|
||||
documents = append(documents, data2)
|
||||
|
||||
// for key, doc := range documents {
|
||||
// // first is string returned, second is struct searched
|
||||
// index.Index(doc.Path, doc)
|
||||
// }
|
||||
|
||||
// for i := 0; i < len(documents); i++ {
|
||||
// fmt.Print(documents[i])
|
||||
// }
|
||||
|
||||
return index
|
||||
}
|
||||
|
||||
func getFile(path string) string {
|
||||
buf, err := os.ReadFile(path)
|
||||
notecontent := string(buf)
|
||||
|
||||
if err != nil {
|
||||
fmt.Print("Error Reading File")
|
||||
os.Exit(1)
|
||||
}
|
||||
return notecontent
|
||||
}
|
||||
|
||||
func delete_index(path string) {
|
||||
os.RemoveAll(path)
|
||||
}
|
||||
|
||||
func listFiles() []string {
|
||||
files := []string{}
|
||||
|
||||
// TODO Why is this different?
|
||||
// https://stackoverflow.com/a/42423998
|
||||
// https://flaviocopes.com/go-list-files/
|
||||
echo := func(path string, info os.FileInfo, err error) error {
|
||||
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO there should be many formats allowed
|
||||
if !(filepath.Ext(path) == ".md") {
|
||||
return nil
|
||||
}
|
||||
|
||||
files = append(files, path)
|
||||
|
||||
// fmt.Print(path)
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
// TODO Why not Symlinks?
|
||||
root := "/home/ryan/Sync/Notes/MD/"
|
||||
err := filepath.Walk(root, echo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return files
|
||||
}
|
@@ -1,141 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
|
||||
# * Shell Settings
|
||||
set -o errexit # abort on nonzero exitstatus
|
||||
set -o nounset # abort on unbound variable
|
||||
set -o pipefail # don't hide errors within pipes
|
||||
|
||||
# * Main Function
|
||||
main() {
|
||||
|
||||
# Use STDERR so as to not clog STDIN
|
||||
# Is there a better way to do this?
|
||||
echoerr() { echo -e "$@" 1>&2; }
|
||||
|
||||
|
||||
check_for_dependencies
|
||||
setVars
|
||||
readFirstArgument "${@}"
|
||||
AskValues
|
||||
|
||||
if [ "${promptComplete}" != "Completed" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MakeConfig "${@}"
|
||||
|
||||
}
|
||||
|
||||
# ** Helper Functions
|
||||
# *** Check for Dependencies
|
||||
check_for_dependencies () {
|
||||
|
||||
for i in ${DependArray[@]}; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** List of Dependencies
|
||||
|
||||
declare -a DependArray=(
|
||||
"jq"
|
||||
"cat"
|
||||
"xclip"
|
||||
)
|
||||
|
||||
|
||||
# *** Set variables below main
|
||||
setVars () {
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
}
|
||||
|
||||
# **** Print Help
|
||||
Help () {
|
||||
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1mMakeConfig.sh \e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m--------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||
echo
|
||||
echo -e " "${script_name}" [-h]"
|
||||
echo -e " "${script_name}" [--help]"
|
||||
echo
|
||||
echo -e " Fully Interactive, just follow the prompts"
|
||||
echo
|
||||
echo -e " \e[3m By Design: No Options; No Arguments\e[0m"
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||
echo
|
||||
echo -e " This prints everything to STDERR to that STDOUT only has"
|
||||
echo -e " The config file in it, I'm not sure if that's an issue "
|
||||
echo
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
# *** Read First Argument
|
||||
readFirstArgument () {
|
||||
|
||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
|
||||
Help && exit 0
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# ***
|
||||
AskValues () {
|
||||
echoerr "Please Enter the Directory of you Markdown Files"
|
||||
echoerr "\t (This directory should contain index.md or home.md)"
|
||||
read -e NOTES_DIR
|
||||
NOTES_DIR="$(echo "${NOTES_DIR/\~/$HOME}")"
|
||||
# NOTES_DIR="$(cd /; sk --height 40% -i -c 'fd {}' )"
|
||||
[[ -d "${NOTES_DIR}" ]] || echoerr -e "\n \e[3m\e[1m \e[1;31m ⚠ WARNING: \e[0m No Such Directory!"
|
||||
|
||||
|
||||
echoerr "\nPlease Enter the Directory of the recoll config you want to use"
|
||||
echoerr "\t Leave it blank to use the default config"
|
||||
echoerr "\t This is not implemented so don't worry"
|
||||
read -e RECOLL_CONFIG_DIR
|
||||
RECOLL_CONFIG_DIR="$(echo "${RECOLL_CONFIG_DIR/\~/$HOME}")"
|
||||
[[ -d "${RECOLL_CONFIG_DIR}" ]] || echoerr "\n \e[3m\e[1m \e[1;31m ⚠ WARNING: \e[0m No Such Directory!"
|
||||
|
||||
echoerr "\nPlease Enter the location of your mkdocs yml"
|
||||
echoerr "\t (If you're not going to use this just leave it blank and press Enter)"
|
||||
read -e MKDOCS_YML
|
||||
MKDOCS_YML="$(echo "${MKDOCS_YML/\~/$HOME}")"
|
||||
[[ -f "${MKDOCS_YML}" ]] || echoerr -e "\n \e[3m\e[1m \e[1;31m ⚠ WARNING: \e[0m No Such File!"
|
||||
|
||||
echoerr "\nPlease Enter the Directory in which you want mkdocs to build your static site"
|
||||
echoerr "\t (If you're not going to use this just leave it blank and press Enter)"
|
||||
read -e SERVER_DIR
|
||||
SERVER_DIR="$(echo "${SERVER_DIR/\~/$HOME}")"
|
||||
[[ -d "${SERVER_DIR}" ]] || echoerr -e "\n \e[3m\e[1m \e[1;31m ⚠ WARNING: \e[0m No Such Directory!"
|
||||
|
||||
promptComplete="Completed"
|
||||
|
||||
}
|
||||
# *** Make Config
|
||||
MakeConfig () {
|
||||
|
||||
JSON_STRING=$( jq -n \
|
||||
--arg nd "$NOTES_DIR" \
|
||||
--arg sd "$SERVER_DIR" \
|
||||
--arg rc "$RECOLL_CONFIG_DIR" \
|
||||
--arg mk "$MKDOCS_YML" \
|
||||
'{notesDir: $nd, serverDir: $sd, recollConfigDir: $rc, mkdocsConfigDir: $mk}' )
|
||||
|
||||
echo "$JSON_STRING"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
# * Call Main Function
|
||||
main "${@}"
|
@@ -1,329 +0,0 @@
|
||||
/*
|
||||
* I add this to html files generated with pandoc.
|
||||
*/
|
||||
|
||||
html {
|
||||
font-size: 100%;
|
||||
overflow-y: scroll;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-ms-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #444;
|
||||
font-family: Georgia, Palatino, 'Palatino Linotype', Times, 'Times New Roman', serif;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
padding: 1em;
|
||||
margin: auto;
|
||||
max-width: 42em;
|
||||
background: #fefefe;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0645ad;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #0b0080;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #06e;
|
||||
}
|
||||
|
||||
a:active {
|
||||
color: #faa700;
|
||||
}
|
||||
|
||||
a:focus {
|
||||
outline: thin dotted;
|
||||
}
|
||||
|
||||
*::-moz-selection {
|
||||
background: rgba(255, 255, 0, 0.3);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
*::selection {
|
||||
background: rgba(255, 255, 0, 0.3);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
a::-moz-selection {
|
||||
background: rgba(255, 255, 0, 0.3);
|
||||
color: #0645ad;
|
||||
}
|
||||
|
||||
a::selection {
|
||||
background: rgba(255, 255, 0, 0.3);
|
||||
color: #0645ad;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color: #111;
|
||||
line-height: 125%;
|
||||
margin-top: 2em;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h4, h5, h6 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
color: #666666;
|
||||
margin: 0;
|
||||
padding-left: 3em;
|
||||
border-left: 0.5em #EEE solid;
|
||||
}
|
||||
|
||||
hr {
|
||||
display: block;
|
||||
height: 2px;
|
||||
border: 0;
|
||||
border-top: 1px solid #aaa;
|
||||
border-bottom: 1px solid #eee;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
pre, code, kbd, samp {
|
||||
color: #000;
|
||||
font-family: monospace, monospace;
|
||||
_font-family: 'courier new', monospace;
|
||||
font-size: 0.98em;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
b, strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
dfn {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
ins {
|
||||
background: #ff9;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: #ff0;
|
||||
color: #000;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
sub, sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
margin: 1em 0;
|
||||
padding: 0 0 0 2em;
|
||||
}
|
||||
|
||||
li p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ul ul, ol ol {
|
||||
margin: .3em 0;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
margin-bottom: .8em;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0 0 .8em 2em;
|
||||
}
|
||||
|
||||
dd:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
figure {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
figure img {
|
||||
border: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
margin: 0 0 .8em;
|
||||
}
|
||||
|
||||
table {
|
||||
margin-bottom: 2em;
|
||||
border-bottom: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table th {
|
||||
padding: .2em 1em;
|
||||
background-color: #eee;
|
||||
border-top: 1px solid #ddd;
|
||||
border-left: 1px solid #ddd;
|
||||
}
|
||||
|
||||
table td {
|
||||
padding: .2em 1em;
|
||||
border-top: 1px solid #ddd;
|
||||
border-left: 1px solid #ddd;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.author {
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media only screen and (min-width: 480px) {
|
||||
body {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
@media only screen and (min-width: 768px) {
|
||||
body {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
@media print {
|
||||
* {
|
||||
background: transparent !important;
|
||||
color: black !important;
|
||||
filter: none !important;
|
||||
-ms-filter: none !important;
|
||||
}
|
||||
|
||||
body {
|
||||
font-size: 12pt;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 1px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
a[href]:after {
|
||||
content: " (" attr(href) ")";
|
||||
}
|
||||
|
||||
abbr[title]:after {
|
||||
content: " (" attr(title) ")";
|
||||
}
|
||||
|
||||
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after {
|
||||
content: "";
|
||||
}
|
||||
|
||||
pre, blockquote {
|
||||
border: 1px solid #999;
|
||||
padding-right: 1em;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
tr, img {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
@page :left {
|
||||
margin: 15mm 20mm 15mm 10mm;
|
||||
}
|
||||
|
||||
@page :right {
|
||||
margin: 15mm 10mm 15mm 20mm;
|
||||
}
|
||||
|
||||
p, h2, h3 {
|
||||
orphans: 3;
|
||||
widows: 3;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
page-break-after: avoid;
|
||||
}
|
||||
}
|
||||
|
205
bin/rofi_find.sh
205
bin/rofi_find.sh
@@ -1,205 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
||||
|
||||
# * Shell Settings
|
||||
set -o errexit # abort on nonzero exitstatus
|
||||
set -o nounset # abort on unbound variable
|
||||
set -o pipefail # don't hide errors within pipes
|
||||
|
||||
# * Main Function
|
||||
main() {
|
||||
|
||||
check_for_dependencies
|
||||
setVars
|
||||
readFirstArgument "${@}"
|
||||
rofi_over_Notes "${@}"
|
||||
|
||||
}
|
||||
|
||||
# ** Helper Functions
|
||||
# *** Check for Dependencies
|
||||
check_for_dependencies () {
|
||||
|
||||
for i in ${DependArray[@]}; do
|
||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
# **** List of Dependencies
|
||||
|
||||
declare -a DependArray=(
|
||||
"rofi"
|
||||
"rg"
|
||||
)
|
||||
|
||||
|
||||
# *** Set variables below main
|
||||
setVars () {
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
||||
}
|
||||
|
||||
# **** Print Help
|
||||
Help () {
|
||||
|
||||
|
||||
echo
|
||||
echo -e " \e[3m\e[1mNoteFind.sh \e[0m; Helpful Shell Scripts for Markdown Notes"
|
||||
echo -e " \e[1;31m--------------------------\e[0m "
|
||||
echo
|
||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||
echo
|
||||
echo -e " "${script_name}" [<path/to/notes>]"
|
||||
echo -e " "${script_name}" [-h]"
|
||||
echo -e " "${script_name}" [--help]"
|
||||
echo
|
||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
||||
echo
|
||||
# echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
||||
# echo
|
||||
# echo
|
||||
# echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||
# echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
||||
# echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
||||
# echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
||||
# echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
||||
# echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
||||
# echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
||||
# echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
||||
# echo
|
||||
|
||||
# echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||
# echo
|
||||
}
|
||||
|
||||
|
||||
# *** Read First Argument
|
||||
readFirstArgument () {
|
||||
|
||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
||||
Help && exit 0
|
||||
fi
|
||||
|
||||
}
|
||||
# *** Skim and Grep, the important stuff
|
||||
#
|
||||
rofi_over_Notes () {
|
||||
|
||||
## Change directory if One was specified, exit if no directory exists
|
||||
|
||||
cd "${1}"
|
||||
|
||||
FILE="$(RofiFind)"
|
||||
|
||||
if [[ $FILE != "" ]]; then
|
||||
realpath $FILE && exit 0
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
# **** Skim with Grep
|
||||
RofiFind () {
|
||||
|
||||
## Change directory if One was specified, exit if no directory exists
|
||||
|
||||
# I took this bit from https://github.com/davatorium/rofi/issues/997
|
||||
# Not totally sure how it works but it does :shrug
|
||||
|
||||
## Set Variables
|
||||
local selected
|
||||
local string
|
||||
selected="${1:-}"
|
||||
|
||||
TEMP_DIR="/tmp/cadmus_rofi_preview"
|
||||
mkdir -p "${TEMP_DIR}"
|
||||
|
||||
# schemes="$(fd '\.org$')" # TODO Only look at org-mode files (hmmmm)
|
||||
schemes="$(find ./ -name '*\.org' -or -name '*\.md')"
|
||||
lines=$(printf '%s\n' "${schemes}" | wc -l)
|
||||
menu=$(printf '%s\n' "${schemes}" | rofi -matching fuzzy -location 1 -kb-row-up "" -kb-row-down "" -kb-custom-1 "Up" -kb-custom-2 "Down" -format 'd:s' -dmenu -selected-row $selected)
|
||||
|
||||
exit_code=$?
|
||||
|
||||
selected="${menu%:*}"
|
||||
string="${menu##*:}"
|
||||
|
||||
case "${exit_code}" in
|
||||
"1") exit 0;;
|
||||
"0") PRINT_OUT "${string}" & disown;;
|
||||
"10")
|
||||
if [[ $selected == "1" ]]; then
|
||||
foo_selected="${lines}"
|
||||
call="3"
|
||||
else
|
||||
foo_selected="$(echo -e $(( ${selected} - 1 )))";
|
||||
call=$(echo $(( ${selected} - 2 )))
|
||||
fi
|
||||
foo="$(printf '%s' "${schemes}" | sed -n "${foo_selected}"p)";
|
||||
PRINT_OUT "${foo}" & disown;;
|
||||
"11")
|
||||
if [[ "${selected}" -ge "${lines}" ]]; then
|
||||
foo_selected="1"
|
||||
call="0"
|
||||
else
|
||||
foo_selected="$(echo -e $(( ${selected} + 1 )))";
|
||||
call="${selected}"
|
||||
fi
|
||||
foo="$(printf '%s' "${schemes}" | sed -n "${foo_selected}"p)";
|
||||
PRINT_OUT "${foo}" & disown
|
||||
esac
|
||||
|
||||
RofiFind "${call}"
|
||||
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
# **** Convert the File with Pandoc and Show in Browser
|
||||
PRINT_OUT () {
|
||||
FILEPATH="$(realpath ${1})"
|
||||
FILEPATH_NO_EXT="$(realpath ${1} | cut -f 1 -d '.')"
|
||||
DIRECTORY="$(dirname ${FILEPATH}})"
|
||||
NAME="$(basename ${@} | cut -f 1 -d '.')"
|
||||
|
||||
BROWSER="chromium"
|
||||
|
||||
# Simpler calls
|
||||
# pandoc -f org -t html "${FILEPATH}" --quiet | cat
|
||||
|
||||
function pandoc_browser() {
|
||||
#pandoc -f org -t html "${FILEPATH}" -A /home/ryan/Templates/CSS/gitOrgWrapped.css --mathjax -s --quiet -o "/dev/shm/${NAME}.html" && \
|
||||
pandoc -t html "${FILEPATH}" --extract-media="${TEMP_DIR}/media_${NAME}" -A /home/ryan/Templates/CSS/gitOrgWrapped.css --katex -s --quiet -o "${TEMP_DIR}/${NAME}.html" && \
|
||||
"${BROWSER}" "${TEMP_DIR}/${NAME}.html" > /dev/null & disown # Chromium is faster than firefox
|
||||
}
|
||||
|
||||
## By caching the export in /dev/shm/ chrome will just go back to the last tab (quicker)
|
||||
## and pandoc won't reconvert unnecessarily (quicker)
|
||||
## Given that most of the time is spent looking and reading this makes a lot of sense
|
||||
|
||||
if [ "${FILEPATH}" -nt "${TEMP_DIR}/${NAME}.html" ]; then
|
||||
# The Live_Reload_JS lets me reload this, otherwise do not disown this process
|
||||
pandoc_browser & disown
|
||||
else
|
||||
"${BROWSER}" "${TEMP_DIR}/${NAME}.html" & disown
|
||||
fi
|
||||
|
||||
# I tried this with org-ruby, no luck though for latex though
|
||||
# Org-ruby is much faster than pandoc
|
||||
# /home/ryan/.gem/ruby/2.7.0/bin/org-ruby "${FILEPATH}" -t html > /dev/shm/mpv.html
|
||||
# cat /home/ryan/Templates/mathjax >> /dev/shm/mpv.html
|
||||
# cat /home/ryan/Templates/CSS/gitOrgWrapped.css >> /dev/shm/mpv.html
|
||||
# chromium /dev/shm/mpv.html & disown
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# * Call Main Function
|
||||
main "${@}"
|
@@ -1,211 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
readonly script_name=$(basename "${0}")
|
||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
if [[ "${1:-}" != "" ]]; then
|
||||
readonly NOTES_DIR="${1}"
|
||||
else
|
||||
readonly NOTES_DIR="./"
|
||||
fi
|
||||
|
||||
function main() {
|
||||
|
||||
|
||||
DEFAULTAPP=code ## TODO Should this be xdg-open?
|
||||
takeArguments $1
|
||||
checkDependencies
|
||||
regenTags
|
||||
|
||||
ConcurrentTags="$(tmsu tags)"
|
||||
FilterTags
|
||||
|
||||
makeSymlinks
|
||||
|
||||
echo -e "
|
||||
⁍ \e[1;35mv\e[0m :: Open all matching files with \e[1;35mV\e[0mSCode
|
||||
⁍ \e[1;35mc\e[0m :: \e[1;35mC\e[0mhoose a file to open
|
||||
⁍ AnyKey :: Create Symlinks in $TEMPDIR
|
||||
"
|
||||
|
||||
openMatches
|
||||
|
||||
|
||||
}
|
||||
|
||||
function checkDependencies() {
|
||||
command -v rg >/dev/null 2>&1 || { echo >&2 "I require ripgrep but it's not installed. Aborting."; exit 1; }
|
||||
command -v sd >/dev/null 2>&1 || { echo >&2 "I require sd (sed replacement) but it's not installed. Aborting."; exit 1; }
|
||||
command -v tmsu >/dev/null 2>&1 || { echo >&2 "I require TMSU but it's not installed. Aborting."; exit 1; }
|
||||
}
|
||||
|
||||
|
||||
function regenTags() {
|
||||
echo -e "
|
||||
To begin Tag Selection press any key
|
||||
|
||||
r :: regenerate Tags"
|
||||
|
||||
read -d '' -s -n1 continueQ
|
||||
|
||||
if [ "$continueQ" == "r" ]; then
|
||||
"${script_dir}/tags-to-TMSU.sh" "${NOTES_DIR}" ${@:-} && exit 0
|
||||
exit 0 ## Must Exit because it won't find the tags without restarting.
|
||||
fi
|
||||
}
|
||||
|
||||
function takeArguments() {
|
||||
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
||||
printHelp
|
||||
exit 0
|
||||
elif [[ $1 != '' ]]; then
|
||||
NOTE_DIR=$1
|
||||
cd $NOTE_DIR
|
||||
else
|
||||
NOTE_DIR='./'
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
echo "Either Specify the Directory as an argument or it
|
||||
will run in the current Directory, otherwise this is interactive and doesn't
|
||||
provide STDOUT"
|
||||
}
|
||||
|
||||
function makeSymlinks() {
|
||||
rm -r $TEMPDIR ## If you want to have or logic for tags, the selections
|
||||
## must persist over iterations
|
||||
mkdir $TEMPDIR 2>/dev/null
|
||||
|
||||
|
||||
for i in $MatchingFiles; do
|
||||
ln -s $(realpath $i) /tmp/00tagMatches 2>/dev/null
|
||||
done
|
||||
echo "SymLinks Made in $TEMPDIR"
|
||||
}
|
||||
|
||||
function openMatches() {
|
||||
|
||||
read -d '' -n1 -s openQ
|
||||
|
||||
if [ "$openQ" == "c" ]; then
|
||||
cd $TEMPDIR
|
||||
## sk --ansi -i -c 'rg --color=always -l "{}"' --preview "mdcat {}" \
|
||||
## --bind pgup:preview-page-up,pgdn:preview-page-down
|
||||
sk --ansi --preview "mdcat {}" \
|
||||
--bind pgup:preview-page-up,pgdn:preview-page-down | \
|
||||
xargs realpath | xargs $DEFAULTAPP -a
|
||||
elif [ "$openQ" == "v" ]; then
|
||||
|
||||
for i in "$MatchingFiles"; do
|
||||
|
||||
code -a $i
|
||||
|
||||
done
|
||||
|
||||
else
|
||||
echo "The following files were symlinked in $TEMPDIR:"
|
||||
echo -e "~~~~~~~~~~~~
|
||||
|
||||
\e[1;34m $(ls $TEMPDIR)\e[0m"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
FilterTags() {
|
||||
chooseValue=$(echo "$ConcurrentTags" | fzf)
|
||||
ChosenTags=$(echo -e ""$ChosenTags"\n"$chooseValue"")
|
||||
ChosenTags="$ChosenTags "
|
||||
MatchingFiles=$(tmsu files "$ChosenTags")
|
||||
ConcurrentTags=$(tmsu tags $MatchingFiles | cut -f 2 -d ':' | space2NewLine | sort | uniq | sort -nr )
|
||||
ChosenTags=$(echo "$ChosenTags" | space2NewLine | sort -u )
|
||||
ConcurrentTags="$(comm -13 <(echo "$ChosenTags" | sort) <(echo "$ConcurrentTags" | sort))"
|
||||
|
||||
echo -e "
|
||||
|
||||
\e[1;32m
|
||||
═══════════════════════════════════════════════════════════════════════════
|
||||
\e[0m
|
||||
|
||||
The chosen tags are:
|
||||
|
||||
\e[1;35m
|
||||
$(addBullets "$ChosenTags")
|
||||
\e[0m
|
||||
|
||||
With Matching Files:
|
||||
|
||||
\e[1;34m
|
||||
$(addBullets "$MatchingFiles")
|
||||
\e[0m
|
||||
|
||||
and Concurrent Tags:
|
||||
\e[1;33m
|
||||
$(addBullets "$ConcurrentTags")
|
||||
\e[0m
|
||||
\e[1;32m
|
||||
═══════════════════════════════════════════════════════════════════════════
|
||||
\e[0m
|
||||
"
|
||||
|
||||
## read -p 'Press t to continue chosing Tags concurrently: ' conTagQ
|
||||
## This temp dir doesn't work ??? TODO
|
||||
## TEMPDIR="$(mktemp -d /tmp/cadmusTagsXXXXXXX)"
|
||||
TEMPDIR=/tmp/00tagMatches
|
||||
echo -e "
|
||||
|
||||
|
||||
⁍ \e[1;35mt\e[0m :: Choose Concurrent \e[1;35mT\e[0mags
|
||||
⁍ AnyKey :: Accept Chosen Tags \e[1;35mT\e[0mags
|
||||
"
|
||||
|
||||
read -d '' -n1 -s conTagQ
|
||||
|
||||
|
||||
if [ "$conTagQ" == "t" ]; then
|
||||
FilterTags
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
space2NewLine() {
|
||||
command -v perl >/dev/null 2>&1 || { echo >&2 "I require perl but it's not installed. Aborting."; exit 1; }
|
||||
perl -pe 's/(?<=[^\\])\ /\n/g' | rmLeadingWS
|
||||
}
|
||||
|
||||
## For some reason the first TagResult has a leading whitespace which causes it to double up
|
||||
## This function strips whitespace and so needs to be used
|
||||
rmLeadingWS() {
|
||||
command -v sd >/dev/null 2>&1 || { echo >&2 "I require sd (sed replacement) but it's not installed. Aborting."; exit 1; }
|
||||
sd '^ ' ''
|
||||
}
|
||||
|
||||
addBullets() {
|
||||
echo "$1" | perl -pe 's/^(?=.)/\t‣\ /g'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
main $1
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# DONE Chosen Tags Should not be listed also as concurrent Tags
|
||||
# DONE Should get an MDCat Preview
|
||||
# DONE Should get Bullets and Horizontal Rules
|
||||
# DONE Initial Tag
|
||||
# DONE Coloured Output
|
||||
# DONE Output should be useful
|
||||
# DONE fif should use `rg --follow` by default
|
||||
# DONE Should not call code when C-c out
|
||||
# DONE Should Cleare Symlink Folder after Running
|
||||
# DONE Should the option to regen tags present itself?
|
||||
# TODO Restructure
|
||||
## Seperate Script
|
||||
# DONE fimd should use mdcat by default as well as skim interactive
|
@@ -1,116 +0,0 @@
|
||||
StartTime <- Sys.time()
|
||||
|
||||
#### *** Load or Install RMarkdown ###############################################
|
||||
|
||||
if(require('rmarkdown')){
|
||||
library('rmarkdown')
|
||||
}else{
|
||||
install.packages('rmarkdown')
|
||||
library('rmarkdown')
|
||||
}
|
||||
|
||||
if(require('R.utils')){
|
||||
library('R.utils')
|
||||
}else{
|
||||
install.packages('R.utils')
|
||||
library('R.utils')
|
||||
}
|
||||
##### Load or Install dplyr ###################################################
|
||||
if(require('dplyr')){
|
||||
library('dplyr')
|
||||
}else{
|
||||
install.packages('dplyr')
|
||||
library('dplyr')
|
||||
}
|
||||
|
||||
##### Load or Install Purrr ######################################################
|
||||
|
||||
if(require('purrr')){
|
||||
library('purrr')
|
||||
}else{
|
||||
install.packages('purrr')
|
||||
library('purrr')
|
||||
}
|
||||
|
||||
setwd("~/Notes")
|
||||
|
||||
#### List all the Notes with a YAML Header =======================================
|
||||
noteFiles <- c(dir(pattern="*.Rmd", recursive = TRUE),
|
||||
dir(pattern="*.md", recursive = TRUE),
|
||||
dir(pattern="*.txt", recursive = TRUE),
|
||||
dir(pattern="*.markdown", recursive = TRUE)
|
||||
)
|
||||
|
||||
|
||||
# Generate Symlinks
|
||||
|
||||
## I was playing with the idea of creating the symlinks as well
|
||||
## But I don't think there is any need to do this when I could just pass
|
||||
## the tags to TMSU which I've implemented in another script.
|
||||
## I'll leave this in here though because it might be useful later somwehre?
|
||||
|
||||
gen_symlinks <- function(file) {
|
||||
|
||||
for (tagDirPath in MDTags) {
|
||||
#actDirPath <- paste0("./00Notebooks/", tagDirPath)
|
||||
actDirPath <- paste0("~/Documents/00Notebooks/", tagDirPath)
|
||||
dir.create(path = actDirPath, recursive = TRUE)
|
||||
linkPath=paste0( actDirPath, "/", file)
|
||||
print(paste("Symlink from", file, "to", linkPath))
|
||||
createLink(link = linkPath, target = file)
|
||||
}
|
||||
}
|
||||
|
||||
#### Run For Loop over Yaml ======================================================
|
||||
# Create an empty dynamic Vector
|
||||
tagVector <- c()
|
||||
|
||||
# Run the following code over the entire folder
|
||||
c=0
|
||||
for (i in noteFiles){
|
||||
c = c + 1
|
||||
yamlExtract <- yaml_front_matter(input = i )
|
||||
MDTags <- (yamlExtract$tags)
|
||||
tagVector <- c(MDTags, tagVector)
|
||||
|
||||
gen_symlinks(i) # adds a lotof time.
|
||||
}
|
||||
#tagVector <- flatten_chr(tagVector)
|
||||
|
||||
EndTime <- Sys.time()
|
||||
|
||||
#### Remove Repetition ===========================================================
|
||||
cat("\n")
|
||||
tagVector <- as.matrix(tagVector)
|
||||
tagVector <- unique(tagVector)
|
||||
|
||||
#### Write to a CSV ===============================================================
|
||||
# Write a document containing all the tags
|
||||
# write.csv(tagVector, file = "~/Desktop/YamlScript/tags.csv", quote = TRUE, row.names = FALSE)
|
||||
write.csv(tagVector, file = "/tmp/00tags.csv", quote = FALSE, row.names = FALSE)
|
||||
|
||||
|
||||
#### Optional Arguments =========================================================
|
||||
# Print Statement
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args)!=0) {
|
||||
if (args[1]=="p" | args[1]=="-p") {
|
||||
print(tagFreq) # I could list this by frequency
|
||||
}
|
||||
if (args[1]=="--help" | args[1]=="-h") {
|
||||
print("Using the p argument will print the tags")
|
||||
}
|
||||
}
|
||||
|
||||
print(paste(length(tagVector), "Tags Successfully Generated in ",
|
||||
round((EndTime- StartTime),3)*1000, "MilliSeconds")
|
||||
)
|
||||
|
||||
|
||||
## Now just add the following to `.vimrc`
|
||||
## imap <expr> <C-c><C-y> fzf#vim#complete('Rscript ~/bin/ListTags.R > /dev/null 2>&1; cat /tmp/00tags.csv')
|
||||
|
||||
|
||||
## vim:fdm=expr:fdl=0
|
||||
## vim:fde=getline(v\:lnum)=~'^##'?'>'.(matchend(getline(v\:lnum),'##*')-2)\:'='
|
@@ -1,52 +0,0 @@
|
||||
#+TITLE: Tag Tools
|
||||
|
||||
#+begin_center
|
||||
*/ [[file:~/DotFiles/Note-Taking-Tools/auto-complete-tags-vim/printMarkdownTags/README.org][See Also this README which is mostly identical]]/*
|
||||
#+end_center
|
||||
|
||||
* yaml-tags-to-TMSU.js
|
||||
This takes a directory as it's first and only argument.
|
||||
|
||||
It will print back the commands necessary to build tmsu tags that correspond to the YAML headers in markdown files.
|
||||
|
||||
Pipe this to bash.
|
||||
|
||||
** yaml-to-TMSU.R
|
||||
This works identically to yaml-tags-to-TMSU, I wrote it first because I'm more familiar with **/R/** but it's a bit slow.
|
||||
* yaml-parse.js
|
||||
This takes a directory as it's first and only argument.
|
||||
|
||||
It will print out all the yaml tags, pipe this to =sort -u= if you only want the unique tags.
|
||||
|
||||
** ListTags.R
|
||||
This works identically to yaml-parse, I wrote it first because I'm more familiar with **/R/** but it's a bit slow.
|
||||
|
||||
* tags-to-TMSU.sh
|
||||
This takes a directory as its first and only argument, its expected that directory will contain both:
|
||||
|
||||
1. a =.tmsu directory=
|
||||
- or atleast be beneath one
|
||||
- It won't delete any =.tmsu= folders above it, only within that
|
||||
directory.
|
||||
2. Have Markdown Notes within or beneath it.
|
||||
|
||||
|
||||
This script operates within the specified directory to either build tags
|
||||
|
||||
* TODO FilterNotesByTMSUTag.sh
|
||||
|
||||
* hashtags.sh
|
||||
This is dumps =#tags= from notes using =rg=.
|
||||
* node_modules
|
||||
These are dependencies for the javascrit in here, so definitely leave them be.
|
||||
|
||||
* Working with Vim
|
||||
** Yaml Tags
|
||||
#+begin_src bash
|
||||
imap <expr> <C-c><C-y> fzf#vim#complete('node ~/bin/printMarkdownTags/yaml-parse.js $HOME/Notes/MD/notes \| sort -u')
|
||||
#+end_src
|
||||
|
||||
** Hash Tags
|
||||
#+begin_src bash
|
||||
imap <expr> <C-c><C-t> fzf#vim#complete('rg --pcre2 "\s#[a-zA-Z-@]+\s" -o --no-filename $HOME/Notes/MD -t md \| sort -u')
|
||||
#+end_src
|
@@ -1,173 +0,0 @@
|
||||
###############################################################################
|
||||
## Extract YAML tags and create text file that lists ##
|
||||
## each command to create the corresponding tmsu tags. ##
|
||||
## ##
|
||||
## * Create a Text file of commands so there is an opportunity to review the ##
|
||||
## commands before they are executed ##
|
||||
## * Don't print the tags to STDOUT because trying to fight messages ##
|
||||
## from errors etc. becomes a PITA ##
|
||||
###############################################################################
|
||||
|
||||
StartTime <- Sys.time()
|
||||
|
||||
#### *** Load or Install RMarkdown ###############################################
|
||||
if(require('rmarkdown')){
|
||||
library('rmarkdown', quietly = TRUE)
|
||||
}else{
|
||||
install.packages('rmarkdown')
|
||||
library('rmarkdown', quietly = TRUE)
|
||||
}
|
||||
|
||||
if(require('R.utils')){
|
||||
library('R.utils', quietly = TRUE)
|
||||
}else{
|
||||
install.packages('R.utils')
|
||||
library('R.utils', quietly = TRUE)
|
||||
}
|
||||
|
||||
##### Load or Install dplyr ###################################################
|
||||
if(require('dplyr')){
|
||||
library('dplyr', quietly = TRUE)
|
||||
}else{
|
||||
install.packages('dplyr')
|
||||
library('dplyr', quietly = TRUE)
|
||||
}
|
||||
|
||||
##### Load or Install Purrr ######################################################
|
||||
if(require('purrr')){
|
||||
library('purrr', quietly = TRUE )
|
||||
}else{
|
||||
install.packages('purrr')
|
||||
library('purrr', quietly = TRUE)
|
||||
}
|
||||
|
||||
#### Set Working Directory (Actually Don't) =====================================
|
||||
|
||||
########################################################################################
|
||||
## Setting the working Directory is a bit of a nuisance, there are a few options: ##
|
||||
## ##
|
||||
## 1. Hardcode the working directory (easiest) ##
|
||||
## 2. Take an optional Argument (moderate) ##
|
||||
## 3. Set the working directory as the file location (suprisingly complicated) ##
|
||||
## ##
|
||||
## For this reason I''ve chosen to just hardcode it, I may want to consider, however, ##
|
||||
## changing this to an argument. ##
|
||||
########################################################################################
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
|
||||
if (length(args)!=0) {
|
||||
if (args[1]=="--help" | args[1]=="-h") {
|
||||
print("First Argument should be the notes parent directory,
|
||||
this will go through all MD files, extract the yaml
|
||||
tags and save them in tmp`")
|
||||
} else {
|
||||
DIR <- args[1]
|
||||
}
|
||||
} else {
|
||||
DIR <- "~/Notes/MD/notes"
|
||||
}
|
||||
setwd(DIR)
|
||||
|
||||
|
||||
|
||||
|
||||
#### List all the Notes with a YAML Header =======================================
|
||||
# TODO use regex not slow list building
|
||||
|
||||
noteFiles <- c(dir(pattern="*.Rmd", recursive = TRUE),
|
||||
dir(pattern="*.md", recursive = TRUE),
|
||||
dir(pattern="*.txt", recursive = TRUE),
|
||||
dir(pattern="*.markdown", recursive = TRUE))
|
||||
|
||||
##########################################################################################
|
||||
## It isnt too hard to generate symlinks corresponding to the tags, see ##
|
||||
## ``~/bin/ListTags.R` but I found this to be convoluted and the results, subpar, if ##
|
||||
## TMSU wasnt available this would be possible though! but it would be a bit tricky :/. ##
|
||||
##########################################################################################
|
||||
|
||||
#### Run For Loop over Yaml ======================================================
|
||||
# Create an empty dynamic Vector
|
||||
tagVector <- c()
|
||||
|
||||
## Run the following code over the entire folder
|
||||
|
||||
for (i in noteFiles){
|
||||
|
||||
yamlExtract <- yaml_front_matter(input = i)
|
||||
MDTags <- (yamlExtract$tags)
|
||||
MDTags <- as.character(MDTags)
|
||||
|
||||
## Consider Removing the Notebooks Tag?
|
||||
# MDTags <- gsub("Notebooks/", "", MDTags)
|
||||
|
||||
## Different tags are denoted by "/" characters and so
|
||||
## should be seperated
|
||||
MDTags <- unlist(strsplit(MDTags, "/", fixed = FALSE))
|
||||
|
||||
## If a note doesn't have tags then the it should not become
|
||||
## command so only add them if it is not null
|
||||
if(!is.null(MDTags)) {
|
||||
|
||||
## Tag Names can have spaces so use '' to hide those
|
||||
## spaces from the shell
|
||||
## If you add quote marks it will no longer be null
|
||||
#3 So make sure to add these inside the test
|
||||
MDTags <- paste0("'", MDTags, "'")
|
||||
|
||||
MDTags <- c(paste(i, MDTags))
|
||||
}
|
||||
|
||||
## Finally join the tags for this note to the list of all tags
|
||||
tagVector <- c(MDTags, tagVector)
|
||||
## gen_symlinks(i) # adds a lotof time.
|
||||
}
|
||||
|
||||
|
||||
EndTime <- Sys.time()
|
||||
|
||||
#### Add the command prefix to the file and tags===================================
|
||||
if (length(tagVector) >0 ) {
|
||||
tagVector <- as.matrix(tagVector)
|
||||
} else {
|
||||
print("The Tags were not generated")
|
||||
}
|
||||
tagVector <- paste("tmsu tag", tagVector)
|
||||
|
||||
#### Add a CD Command
|
||||
tagVector <- c(paste('cd', DIR), tagVector)
|
||||
tagVector <- c("#!/bin/bash", tagVector)
|
||||
|
||||
|
||||
#### Write to a CSV ===============================================================
|
||||
# Write a document containing all the tags
|
||||
|
||||
fileLocation <- "/tmp/00tags.sh"
|
||||
write.table(tagVector, file = fileLocation, quote = FALSE,
|
||||
row.names = FALSE, col.names = FALSE)
|
||||
|
||||
## Tell the user that it worked
|
||||
print(paste("Output saved to", fileLocation))
|
||||
print(paste("You essentially want to run cat", fileLocation, "| bash"))
|
||||
print("Just make sure to check over the commands that will be run")
|
||||
|
||||
#### Optional Arguments =========================================================
|
||||
# Print Statement
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
if (length(args)!=0) {
|
||||
if (args[1]=="p" | args[1]=="-p") {
|
||||
print(tagVector)
|
||||
}
|
||||
if (args[1]=="--help" | args[1]=="-h") {
|
||||
print("Using the p argument will print the tags")
|
||||
}
|
||||
}
|
||||
|
||||
print(paste(length(tagVector), "Tags Successfully Generated in ", round((EndTime- StartTime),3)*1000, "MilliSeconds"))
|
||||
|
||||
|
||||
|
||||
|
||||
## vim:fdm=expr:fdl=0
|
||||
## vim:fde=getline(v\:lnum)=~'^##'?'>'.(matchend(getline(v\:lnum),'##*')-2)\:'='
|
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $1 != '' ]]; then
|
||||
NOTE_DIR="$1"
|
||||
else
|
||||
NOTE_DIR='./'
|
||||
fi
|
||||
|
||||
|
||||
## Change to directory so paths are relative to notes dir
|
||||
cd $NOTE_DIR
|
||||
|
||||
## We're going to pipe this back into bash, so we need to make sure bash
|
||||
## changes to the correct directory before running running any
|
||||
## tmsu commands
|
||||
|
||||
echo "cd $NOTE_DIR"
|
||||
|
||||
## This will generate the commands to tag the files wit #tags
|
||||
rg --pcre2 '(?<=\s#)[a-zA-Z]+(?=\s)' -t markdown -o $NOTE_DIR \
|
||||
| sed s+:+\ + | sed s/^/tmsu\ tag\ /
|
1
bin/tags/node_modules/.bin/esparse
generated
vendored
1
bin/tags/node_modules/.bin/esparse
generated
vendored
@@ -1 +0,0 @@
|
||||
../esprima/bin/esparse.js
|
1
bin/tags/node_modules/.bin/esvalidate
generated
vendored
1
bin/tags/node_modules/.bin/esvalidate
generated
vendored
@@ -1 +0,0 @@
|
||||
../esprima/bin/esvalidate.js
|
1
bin/tags/node_modules/.bin/js-yaml
generated
vendored
1
bin/tags/node_modules/.bin/js-yaml
generated
vendored
@@ -1 +0,0 @@
|
||||
../js-yaml/bin/js-yaml.js
|
1
bin/tags/node_modules/.bin/yaml-front-matter
generated
vendored
1
bin/tags/node_modules/.bin/yaml-front-matter
generated
vendored
@@ -1 +0,0 @@
|
||||
../yaml-front-matter/bin/js-yaml-front.js
|
185
bin/tags/node_modules/argparse/CHANGELOG.md
generated
vendored
185
bin/tags/node_modules/argparse/CHANGELOG.md
generated
vendored
@@ -1,185 +0,0 @@
|
||||
1.0.10 / 2018-02-15
|
||||
------------------
|
||||
|
||||
- Use .concat instead of + for arrays, #122.
|
||||
|
||||
|
||||
1.0.9 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Rerelease after 1.0.8 - deps cleanup.
|
||||
|
||||
|
||||
1.0.8 / 2016-09-29
|
||||
------------------
|
||||
|
||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
||||
|
||||
|
||||
1.0.7 / 2016-03-17
|
||||
------------------
|
||||
|
||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
||||
|
||||
|
||||
1.0.6 / 2016-02-06
|
||||
------------------
|
||||
|
||||
- Maintenance: moved to eslint & updated CS.
|
||||
|
||||
|
||||
1.0.5 / 2016-02-05
|
||||
------------------
|
||||
|
||||
- Removed lodash dependency to significantly reduce install size.
|
||||
Thanks to @mourner.
|
||||
|
||||
|
||||
1.0.4 / 2016-01-17
|
||||
------------------
|
||||
|
||||
- Maintenance: lodash update to 4.0.0.
|
||||
|
||||
|
||||
1.0.3 / 2015-10-27
|
||||
------------------
|
||||
|
||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
||||
|
||||
|
||||
1.0.2 / 2015-03-22
|
||||
------------------
|
||||
|
||||
- Relaxed lodash version dependency.
|
||||
|
||||
|
||||
1.0.1 / 2015-02-20
|
||||
------------------
|
||||
|
||||
- Changed dependencies to be compatible with ancient nodejs.
|
||||
|
||||
|
||||
1.0.0 / 2015-02-19
|
||||
------------------
|
||||
|
||||
- Maintenance release.
|
||||
- Replaced `underscore` with `lodash`.
|
||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
0.1.16 / 2013-12-01
|
||||
-------------------
|
||||
|
||||
- Maintenance release. Updated dependencies and docs.
|
||||
|
||||
|
||||
0.1.15 / 2013-05-13
|
||||
-------------------
|
||||
|
||||
- Fixed #55, @trebor89
|
||||
|
||||
|
||||
0.1.14 / 2013-05-12
|
||||
-------------------
|
||||
|
||||
- Fixed #62, @maxtaco
|
||||
|
||||
|
||||
0.1.13 / 2013-04-08
|
||||
-------------------
|
||||
|
||||
- Added `.npmignore` to reduce package size
|
||||
|
||||
|
||||
0.1.12 / 2013-02-10
|
||||
-------------------
|
||||
|
||||
- Fixed conflictHandler (#46), @hpaulj
|
||||
|
||||
|
||||
0.1.11 / 2013-02-07
|
||||
-------------------
|
||||
|
||||
- Multiple bugfixes, @hpaulj
|
||||
- Added 70+ tests (ported from python), @hpaulj
|
||||
- Added conflictHandler, @applepicke
|
||||
- Added fromfilePrefixChar, @hpaulj
|
||||
|
||||
|
||||
0.1.10 / 2012-12-30
|
||||
-------------------
|
||||
|
||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
||||
support, thanks to @hpaulj
|
||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.9 / 2012-12-27
|
||||
------------------
|
||||
|
||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
||||
- Imrove negative argument parsing, thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.8 / 2012-12-01
|
||||
------------------
|
||||
|
||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
||||
|
||||
|
||||
0.1.7 / 2012-10-14
|
||||
------------------
|
||||
|
||||
- Fixed 'choices' argument parse (issue #16)
|
||||
- Fixed stderr output (issue #15)
|
||||
|
||||
|
||||
0.1.6 / 2012-09-09
|
||||
------------------
|
||||
|
||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.5 / 2012-09-03
|
||||
------------------
|
||||
|
||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
||||
|
||||
|
||||
0.1.4 / 2012-07-30
|
||||
------------------
|
||||
|
||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
||||
|
||||
|
||||
0.1.3 / 2012-06-27
|
||||
------------------
|
||||
|
||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
||||
|
||||
|
||||
0.1.2 / 2012-05-29
|
||||
------------------
|
||||
|
||||
- Added basic tests
|
||||
- Removed excess whitespace in help
|
||||
- Fixed error reporting, when parcer with subcommands
|
||||
called with empty arguments
|
||||
|
||||
|
||||
0.1.1 / 2012-05-23
|
||||
------------------
|
||||
|
||||
- Fixed line wrapping in help formatter
|
||||
- Added better error reporting on invalid arguments
|
||||
|
||||
|
||||
0.1.0 / 2012-05-16
|
||||
------------------
|
||||
|
||||
- First release.
|
21
bin/tags/node_modules/argparse/LICENSE
generated
vendored
21
bin/tags/node_modules/argparse/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
257
bin/tags/node_modules/argparse/README.md
generated
vendored
257
bin/tags/node_modules/argparse/README.md
generated
vendored
@@ -1,257 +0,0 @@
|
||||
argparse
|
||||
========
|
||||
|
||||
[](http://travis-ci.org/nodeca/argparse)
|
||||
[](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
||||
|
||||
|
3
bin/tags/node_modules/argparse/index.js
generated
vendored
3
bin/tags/node_modules/argparse/index.js
generated
vendored
@@ -1,3 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/argparse');
|
146
bin/tags/node_modules/argparse/lib/action.js
generated
vendored
146
bin/tags/node_modules/argparse/lib/action.js
generated
vendored
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* class Action
|
||||
*
|
||||
* Base class for all actions
|
||||
* Do not call in your code, use this class only for inherits your own action
|
||||
*
|
||||
* Information about how to convert command line strings to Javascript objects.
|
||||
* Action objects are used by an ArgumentParser to represent the information
|
||||
* needed to parse a single argument from one or more strings from the command
|
||||
* line. The keyword arguments to the Action constructor are also all attributes
|
||||
* of Action instances.
|
||||
*
|
||||
* ##### Allowed keywords:
|
||||
*
|
||||
* - `store`
|
||||
* - `storeConstant`
|
||||
* - `storeTrue`
|
||||
* - `storeFalse`
|
||||
* - `append`
|
||||
* - `appendConstant`
|
||||
* - `count`
|
||||
* - `help`
|
||||
* - `version`
|
||||
*
|
||||
* Information about action options see [[Action.new]]
|
||||
*
|
||||
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
|
||||
/**
|
||||
* new Action(options)
|
||||
*
|
||||
* Base class for all actions. Used only for inherits
|
||||
*
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `optionStrings` A list of command-line option strings for the action.
|
||||
* - `dest` Attribute to hold the created object(s)
|
||||
* - `nargs` The number of command-line arguments that should be consumed.
|
||||
* By default, one argument will be consumed and a single value will be
|
||||
* produced.
|
||||
* - `constant` Default value for an action with no value.
|
||||
* - `defaultValue` The value to be produced if the option is not specified.
|
||||
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
||||
* None, 'string'.
|
||||
* - `choices` The choices available.
|
||||
* - `required` True if the action must always be specified at the command
|
||||
* line.
|
||||
* - `help` The help describing the argument.
|
||||
* - `metavar` The name to be used for the option's argument with the help
|
||||
* string. If None, the 'dest' value will be used as the name.
|
||||
*
|
||||
* ##### nargs supported values:
|
||||
*
|
||||
* - `N` (an integer) consumes N arguments (and produces a list)
|
||||
* - `?` consumes zero or one arguments
|
||||
* - `*` consumes zero or more arguments (and produces a list)
|
||||
* - `+` consumes one or more arguments (and produces a list)
|
||||
*
|
||||
* Note: that the difference between the default and nargs=1 is that with the
|
||||
* default, a single value will be produced, while with nargs=1, a list
|
||||
* containing a single value will be produced.
|
||||
**/
|
||||
var Action = module.exports = function Action(options) {
|
||||
options = options || {};
|
||||
this.optionStrings = options.optionStrings || [];
|
||||
this.dest = options.dest;
|
||||
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
||||
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
||||
this.defaultValue = options.defaultValue;
|
||||
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
||||
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
||||
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
||||
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
||||
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
||||
|
||||
if (!(this.optionStrings instanceof Array)) {
|
||||
throw new Error('optionStrings should be an array');
|
||||
}
|
||||
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
||||
throw new Error('required should be a boolean');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#getName -> String
|
||||
*
|
||||
* Tells action name
|
||||
**/
|
||||
Action.prototype.getName = function () {
|
||||
if (this.optionStrings.length > 0) {
|
||||
return this.optionStrings.join('/');
|
||||
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
||||
return this.metavar;
|
||||
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
||||
return this.dest;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isOptional -> Boolean
|
||||
*
|
||||
* Return true if optional
|
||||
**/
|
||||
Action.prototype.isOptional = function () {
|
||||
return !this.isPositional();
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isPositional -> Boolean
|
||||
*
|
||||
* Return true if positional
|
||||
**/
|
||||
Action.prototype.isPositional = function () {
|
||||
return (this.optionStrings.length === 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Should be implemented in inherited classes
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
||||
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
* };
|
||||
*
|
||||
**/
|
||||
Action.prototype.call = function () {
|
||||
throw new Error('.call() not defined');// Not Implemented error
|
||||
};
|
53
bin/tags/node_modules/argparse/lib/action/append.js
generated
vendored
53
bin/tags/node_modules/argparse/lib/action/append.js
generated
vendored
@@ -1,53 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppend
|
||||
*
|
||||
* This action stores a list, and appends each argument value to the list.
|
||||
* This is useful to allow an option to be specified multiple times.
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppend(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
* Note: options.nargs should be optional for constants
|
||||
* and more then zero for other
|
||||
**/
|
||||
var ActionAppend = module.exports = function ActionAppend(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for append actions must be > 0; if arg ' +
|
||||
'strings are not supplying the value to append, ' +
|
||||
'the append const action may be more appropriate');
|
||||
}
|
||||
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppend, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppend.prototype.call = function (parser, namespace, values) {
|
||||
var items = (namespace[this.dest] || []).slice();
|
||||
items.push(values);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
47
bin/tags/node_modules/argparse/lib/action/append/constant.js
generated
vendored
47
bin/tags/node_modules/argparse/lib/action/append/constant.js
generated
vendored
@@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppendConstant
|
||||
*
|
||||
* This stores a list, and appends the value specified by
|
||||
* the const keyword argument to the list.
|
||||
* (Note that the const keyword argument defaults to null.)
|
||||
* The 'appendConst' action is typically useful when multiple
|
||||
* arguments need to store constants to the same list.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppendConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for appendAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppendConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
||||
var items = [].concat(namespace[this.dest] || []);
|
||||
items.push(this.constant);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
40
bin/tags/node_modules/argparse/lib/action/count.js
generated
vendored
40
bin/tags/node_modules/argparse/lib/action/count.js
generated
vendored
@@ -1,40 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionCount
|
||||
*
|
||||
* This counts the number of times a keyword argument occurs.
|
||||
* For example, this is useful for increasing verbosity levels
|
||||
*
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionCount(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionCount = module.exports = function ActionCount(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionCount, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionCount.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
};
|
47
bin/tags/node_modules/argparse/lib/action/help.js
generated
vendored
47
bin/tags/node_modules/argparse/lib/action/help.js
generated
vendored
@@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionHelp
|
||||
*
|
||||
* Support action for printing help
|
||||
* This class inherided from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionHelp(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionHelp = module.exports = function ActionHelp(options) {
|
||||
options = options || {};
|
||||
if (options.defaultValue !== null) {
|
||||
options.defaultValue = options.defaultValue;
|
||||
} else {
|
||||
options.defaultValue = c.SUPPRESS;
|
||||
}
|
||||
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
Action.call(this, options);
|
||||
|
||||
};
|
||||
util.inherits(ActionHelp, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionHelp#call(parser, namespace, values, optionString)
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print help and exit
|
||||
**/
|
||||
ActionHelp.prototype.call = function (parser) {
|
||||
parser.printHelp();
|
||||
parser.exit();
|
||||
};
|
50
bin/tags/node_modules/argparse/lib/action/store.js
generated
vendored
50
bin/tags/node_modules/argparse/lib/action/store.js
generated
vendored
@@ -1,50 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStore
|
||||
*
|
||||
* This action just stores the argument’s value. This is the default action.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStore(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStore = module.exports = function ActionStore(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for store actions must be > 0; if you ' +
|
||||
'have nothing to store, actions such as store ' +
|
||||
'true or store const may be more appropriate');
|
||||
|
||||
}
|
||||
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStore, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStore.prototype.call = function (parser, namespace, values) {
|
||||
namespace.set(this.dest, values);
|
||||
};
|
43
bin/tags/node_modules/argparse/lib/action/store/constant.js
generated
vendored
43
bin/tags/node_modules/argparse/lib/action/store/constant.js
generated
vendored
@@ -1,43 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreConstant
|
||||
*
|
||||
* This action stores the value specified by the const keyword argument.
|
||||
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
||||
* The 'store_const' action is most commonly used with optional
|
||||
* arguments that specify some sort of flag.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for storeAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, this.constant);
|
||||
};
|
27
bin/tags/node_modules/argparse/lib/action/store/false.js
generated
vendored
27
bin/tags/node_modules/argparse/lib/action/store/false.js
generated
vendored
@@ -1,27 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreFalse
|
||||
*
|
||||
* This action store the values False respectively.
|
||||
* This is special cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreFalse(options)
|
||||
* - options (object): hash of options see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
||||
options = options || {};
|
||||
options.constant = false;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
26
bin/tags/node_modules/argparse/lib/action/store/true.js
generated
vendored
26
bin/tags/node_modules/argparse/lib/action/store/true.js
generated
vendored
@@ -1,26 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreTrue
|
||||
*
|
||||
* This action store the values True respectively.
|
||||
* This isspecial cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreTrue(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
||||
options = options || {};
|
||||
options.constant = true;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
149
bin/tags/node_modules/argparse/lib/action/subparsers.js
generated
vendored
149
bin/tags/node_modules/argparse/lib/action/subparsers.js
generated
vendored
@@ -1,149 +0,0 @@
|
||||
/** internal
|
||||
* class ActionSubparsers
|
||||
*
|
||||
* Support the creation of such sub-commands with the addSubparsers()
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('../argument/error');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ChoicesPseudoAction(name, help)
|
||||
*
|
||||
* Create pseudo action for correct help text
|
||||
*
|
||||
**/
|
||||
function ChoicesPseudoAction(name, help) {
|
||||
var options = {
|
||||
optionStrings: [],
|
||||
dest: name,
|
||||
help: help
|
||||
};
|
||||
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ChoicesPseudoAction, Action);
|
||||
|
||||
/**
|
||||
* new ActionSubparsers(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
function ActionSubparsers(options) {
|
||||
options = options || {};
|
||||
options.dest = options.dest || c.SUPPRESS;
|
||||
options.nargs = c.PARSER;
|
||||
|
||||
this.debug = (options.debug === true);
|
||||
|
||||
this._progPrefix = options.prog;
|
||||
this._parserClass = options.parserClass;
|
||||
this._nameParserMap = {};
|
||||
this._choicesActions = [];
|
||||
|
||||
options.choices = this._nameParserMap;
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ActionSubparsers, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
||||
* - name (string): sub-command name
|
||||
* - options (object): see [[ArgumentParser.new]]
|
||||
*
|
||||
* Note:
|
||||
* addParser supports an additional aliases option,
|
||||
* which allows multiple strings to refer to the same subparser.
|
||||
* This example, like svn, aliases co as a shorthand for checkout
|
||||
*
|
||||
**/
|
||||
ActionSubparsers.prototype.addParser = function (name, options) {
|
||||
var parser;
|
||||
|
||||
var self = this;
|
||||
|
||||
options = options || {};
|
||||
|
||||
options.debug = (this.debug === true);
|
||||
|
||||
// set program from the existing prefix
|
||||
if (!options.prog) {
|
||||
options.prog = this._progPrefix + ' ' + name;
|
||||
}
|
||||
|
||||
var aliases = options.aliases || [];
|
||||
|
||||
// create a pseudo-action to hold the choice help
|
||||
if (!!options.help || typeof options.help === 'string') {
|
||||
var help = options.help;
|
||||
delete options.help;
|
||||
|
||||
var choiceAction = new ChoicesPseudoAction(name, help);
|
||||
this._choicesActions.push(choiceAction);
|
||||
}
|
||||
|
||||
// create the parser and add it to the map
|
||||
parser = new this._parserClass(options);
|
||||
this._nameParserMap[name] = parser;
|
||||
|
||||
// make parser available under aliases also
|
||||
aliases.forEach(function (alias) {
|
||||
self._nameParserMap[alias] = parser;
|
||||
});
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
ActionSubparsers.prototype._getSubactions = function () {
|
||||
return this._choicesActions;
|
||||
};
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Parse input aguments
|
||||
**/
|
||||
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
||||
var parserName = values[0];
|
||||
var argStrings = values.slice(1);
|
||||
|
||||
// set the parser name if requested
|
||||
if (this.dest !== c.SUPPRESS) {
|
||||
namespace[this.dest] = parserName;
|
||||
}
|
||||
|
||||
// select the parser
|
||||
if (this._nameParserMap[parserName]) {
|
||||
parser = this._nameParserMap[parserName];
|
||||
} else {
|
||||
throw argumentErrorHelper(format(
|
||||
'Unknown parser "%s" (choices: [%s]).',
|
||||
parserName,
|
||||
Object.keys(this._nameParserMap).join(', ')
|
||||
));
|
||||
}
|
||||
|
||||
// parse all the remaining options into the namespace
|
||||
parser.parseArgs(argStrings, namespace);
|
||||
};
|
||||
|
||||
module.exports = ActionSubparsers;
|
47
bin/tags/node_modules/argparse/lib/action/version.js
generated
vendored
47
bin/tags/node_modules/argparse/lib/action/version.js
generated
vendored
@@ -1,47 +0,0 @@
|
||||
/*:nodoc:*
|
||||
* class ActionVersion
|
||||
*
|
||||
* Support action for printing program version
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionVersion(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionVersion = module.exports = function ActionVersion(options) {
|
||||
options = options || {};
|
||||
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
||||
options.dest = (options.dest || c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
this.version = options.version;
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionVersion, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print version and exit
|
||||
**/
|
||||
ActionVersion.prototype.call = function (parser) {
|
||||
var version = this.version || parser.version;
|
||||
var formatter = parser._getFormatter();
|
||||
formatter.addText(version);
|
||||
parser.exit(0, formatter.formatHelp());
|
||||
};
|
482
bin/tags/node_modules/argparse/lib/action_container.js
generated
vendored
482
bin/tags/node_modules/argparse/lib/action_container.js
generated
vendored
@@ -1,482 +0,0 @@
|
||||
/** internal
|
||||
* class ActionContainer
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
//Actions
|
||||
var ActionHelp = require('./action/help');
|
||||
var ActionAppend = require('./action/append');
|
||||
var ActionAppendConstant = require('./action/append/constant');
|
||||
var ActionCount = require('./action/count');
|
||||
var ActionStore = require('./action/store');
|
||||
var ActionStoreConstant = require('./action/store/constant');
|
||||
var ActionStoreTrue = require('./action/store/true');
|
||||
var ActionStoreFalse = require('./action/store/false');
|
||||
var ActionVersion = require('./action/version');
|
||||
var ActionSubparsers = require('./action/subparsers');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('./argument/error');
|
||||
|
||||
/**
|
||||
* new ActionContainer(options)
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `description` -- A description of what the program does
|
||||
* - `prefixChars` -- Characters that prefix optional arguments
|
||||
* - `argumentDefault` -- The default value for all arguments
|
||||
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
||||
**/
|
||||
var ActionContainer = module.exports = function ActionContainer(options) {
|
||||
options = options || {};
|
||||
|
||||
this.description = options.description;
|
||||
this.argumentDefault = options.argumentDefault;
|
||||
this.prefixChars = options.prefixChars || '';
|
||||
this.conflictHandler = options.conflictHandler;
|
||||
|
||||
// set up registries
|
||||
this._registries = {};
|
||||
|
||||
// register actions
|
||||
this.register('action', null, ActionStore);
|
||||
this.register('action', 'store', ActionStore);
|
||||
this.register('action', 'storeConst', ActionStoreConstant);
|
||||
this.register('action', 'storeTrue', ActionStoreTrue);
|
||||
this.register('action', 'storeFalse', ActionStoreFalse);
|
||||
this.register('action', 'append', ActionAppend);
|
||||
this.register('action', 'appendConst', ActionAppendConstant);
|
||||
this.register('action', 'count', ActionCount);
|
||||
this.register('action', 'help', ActionHelp);
|
||||
this.register('action', 'version', ActionVersion);
|
||||
this.register('action', 'parsers', ActionSubparsers);
|
||||
|
||||
// raise an exception if the conflict handler is invalid
|
||||
this._getHandler();
|
||||
|
||||
// action storage
|
||||
this._actions = [];
|
||||
this._optionStringActions = {};
|
||||
|
||||
// groups
|
||||
this._actionGroups = [];
|
||||
this._mutuallyExclusiveGroups = [];
|
||||
|
||||
// defaults storage
|
||||
this._defaults = {};
|
||||
|
||||
// determines whether an "option" looks like a negative number
|
||||
// -1, -1.5 -5e+4
|
||||
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
||||
|
||||
// whether or not there are any optionals that look like negative
|
||||
// numbers -- uses a list so it can be shared and edited
|
||||
this._hasNegativeNumberOptionals = [];
|
||||
};
|
||||
|
||||
// Groups must be required, then ActionContainer already defined
|
||||
var ArgumentGroup = require('./argument/group');
|
||||
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
||||
|
||||
//
|
||||
// Registration methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#register(registryName, value, object) -> Void
|
||||
* - registryName (String) : object type action|type
|
||||
* - value (string) : keyword
|
||||
* - object (Object|Function) : handler
|
||||
*
|
||||
* Register handlers
|
||||
**/
|
||||
ActionContainer.prototype.register = function (registryName, value, object) {
|
||||
this._registries[registryName] = this._registries[registryName] || {};
|
||||
this._registries[registryName][value] = object;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
||||
if (arguments.length < 3) {
|
||||
defaultValue = null;
|
||||
}
|
||||
return this._registries[registryName][value] || defaultValue;
|
||||
};
|
||||
|
||||
//
|
||||
// Namespace default accessor methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#setDefaults(options) -> Void
|
||||
* - options (object):hash of options see [[Action.new]]
|
||||
*
|
||||
* Set defaults
|
||||
**/
|
||||
ActionContainer.prototype.setDefaults = function (options) {
|
||||
options = options || {};
|
||||
for (var property in options) {
|
||||
if ($$.has(options, property)) {
|
||||
this._defaults[property] = options[property];
|
||||
}
|
||||
}
|
||||
|
||||
// if these defaults match any existing arguments, replace the previous
|
||||
// default on the object with the new one
|
||||
this._actions.forEach(function (action) {
|
||||
if ($$.has(options, action.dest)) {
|
||||
action.defaultValue = options[action.dest];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#getDefault(dest) -> Mixed
|
||||
* - dest (string): action destination
|
||||
*
|
||||
* Return action default value
|
||||
**/
|
||||
ActionContainer.prototype.getDefault = function (dest) {
|
||||
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
||||
|
||||
this._actions.forEach(function (action) {
|
||||
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
||||
result = action.defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
//
|
||||
// Adding argument actions
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgument(args, options) -> Object
|
||||
* - args (String|Array): argument key, or array of argument keys
|
||||
* - options (Object): action objects see [[Action.new]]
|
||||
*
|
||||
* #### Examples
|
||||
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
||||
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
||||
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
||||
**/
|
||||
ActionContainer.prototype.addArgument = function (args, options) {
|
||||
args = args;
|
||||
options = options || {};
|
||||
|
||||
if (typeof args === 'string') {
|
||||
args = [ args ];
|
||||
}
|
||||
if (!Array.isArray(args)) {
|
||||
throw new TypeError('addArgument first argument should be a string or an array');
|
||||
}
|
||||
if (typeof options !== 'object' || Array.isArray(options)) {
|
||||
throw new TypeError('addArgument second argument should be a hash');
|
||||
}
|
||||
|
||||
// if no positional args are supplied or only one is supplied and
|
||||
// it doesn't look like an option string, parse a positional argument
|
||||
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
||||
if (args && !!options.dest) {
|
||||
throw new Error('dest supplied twice for positional argument');
|
||||
}
|
||||
options = this._getPositional(args, options);
|
||||
|
||||
// otherwise, we're adding an optional argument
|
||||
} else {
|
||||
options = this._getOptional(args, options);
|
||||
}
|
||||
|
||||
// if no default was supplied, use the parser-level default
|
||||
if (typeof options.defaultValue === 'undefined') {
|
||||
var dest = options.dest;
|
||||
if ($$.has(this._defaults, dest)) {
|
||||
options.defaultValue = this._defaults[dest];
|
||||
} else if (typeof this.argumentDefault !== 'undefined') {
|
||||
options.defaultValue = this.argumentDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// create the action object, and add it to the parser
|
||||
var ActionClass = this._popActionClass(options);
|
||||
if (typeof ActionClass !== 'function') {
|
||||
throw new Error(format('Unknown action "%s".', ActionClass));
|
||||
}
|
||||
var action = new ActionClass(options);
|
||||
|
||||
// throw an error if the action type is not callable
|
||||
var typeFunction = this._registryGet('type', action.type, action.type);
|
||||
if (typeof typeFunction !== 'function') {
|
||||
throw new Error(format('"%s" is not callable', typeFunction));
|
||||
}
|
||||
|
||||
return this._addAction(action);
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
||||
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
||||
*
|
||||
* Create new arguments groups
|
||||
**/
|
||||
ActionContainer.prototype.addArgumentGroup = function (options) {
|
||||
var group = new ArgumentGroup(this, options);
|
||||
this._actionGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
||||
* - options (Object): {required: false}
|
||||
*
|
||||
* Create new mutual exclusive groups
|
||||
**/
|
||||
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
||||
var group = new MutuallyExclusiveGroup(this, options);
|
||||
this._mutuallyExclusiveGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
// resolve any conflicts
|
||||
this._checkConflict(action);
|
||||
|
||||
// add to actions list
|
||||
this._actions.push(action);
|
||||
action.container = this;
|
||||
|
||||
// index the action by any option strings it has
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
self._optionStringActions[optionString] = action;
|
||||
});
|
||||
|
||||
// set the flag if any option strings look like negative numbers
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
if (optionString.match(self._regexpNegativeNumber)) {
|
||||
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
||||
self._hasNegativeNumberOptionals.push(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// return the created action
|
||||
return action;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._removeAction = function (action) {
|
||||
var actionIndex = this._actions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._actions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addContainerActions = function (container) {
|
||||
// collect groups by titles
|
||||
var titleGroupMap = {};
|
||||
this._actionGroups.forEach(function (group) {
|
||||
if (titleGroupMap[group.title]) {
|
||||
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
||||
}
|
||||
titleGroupMap[group.title] = group;
|
||||
});
|
||||
|
||||
// map each action to its group
|
||||
var groupMap = {};
|
||||
function actionHash(action) {
|
||||
// unique (hopefully?) string suitable as dictionary key
|
||||
return action.getName();
|
||||
}
|
||||
container._actionGroups.forEach(function (group) {
|
||||
// if a group with the title exists, use that, otherwise
|
||||
// create a new group matching the container's group
|
||||
if (!titleGroupMap[group.title]) {
|
||||
titleGroupMap[group.title] = this.addArgumentGroup({
|
||||
title: group.title,
|
||||
description: group.description
|
||||
});
|
||||
}
|
||||
|
||||
// map the actions to their new group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
||||
});
|
||||
}, this);
|
||||
|
||||
// add container's mutually exclusive groups
|
||||
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||
// description= then this code will need to be expanded as above
|
||||
var mutexGroup;
|
||||
container._mutuallyExclusiveGroups.forEach(function (group) {
|
||||
mutexGroup = this.addMutuallyExclusiveGroup({
|
||||
required: group.required
|
||||
});
|
||||
// map the actions to their new mutex group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = mutexGroup;
|
||||
});
|
||||
}, this); // forEach takes a 'this' argument
|
||||
|
||||
// add all actions to this container or their group
|
||||
container._actions.forEach(function (action) {
|
||||
var key = actionHash(action);
|
||||
if (groupMap[key]) {
|
||||
groupMap[key]._addAction(action);
|
||||
} else {
|
||||
this._addAction(action);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getPositional = function (dest, options) {
|
||||
if (Array.isArray(dest)) {
|
||||
dest = dest[0];
|
||||
}
|
||||
// make sure required is not specified
|
||||
if (options.required) {
|
||||
throw new Error('"required" is an invalid argument for positionals.');
|
||||
}
|
||||
|
||||
// mark positional arguments as required if at least one is
|
||||
// always required
|
||||
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
||||
options.required = true;
|
||||
}
|
||||
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
||||
options.required = true;
|
||||
}
|
||||
|
||||
// return the keyword arguments with no option strings
|
||||
options.dest = dest;
|
||||
options.optionStrings = [];
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getOptional = function (args, options) {
|
||||
var prefixChars = this.prefixChars;
|
||||
var optionStrings = [];
|
||||
var optionStringsLong = [];
|
||||
|
||||
// determine short and long option strings
|
||||
args.forEach(function (optionString) {
|
||||
// error on strings that don't start with an appropriate prefix
|
||||
if (prefixChars.indexOf(optionString[0]) < 0) {
|
||||
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
||||
optionString,
|
||||
prefixChars
|
||||
));
|
||||
}
|
||||
|
||||
// strings starting with two prefix characters are long options
|
||||
optionStrings.push(optionString);
|
||||
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
||||
optionStringsLong.push(optionString);
|
||||
}
|
||||
});
|
||||
|
||||
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
||||
var dest = options.dest || null;
|
||||
delete options.dest;
|
||||
|
||||
if (!dest) {
|
||||
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
||||
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
||||
|
||||
if (dest.length === 0) {
|
||||
throw new Error(
|
||||
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
||||
);
|
||||
}
|
||||
dest = dest.replace(/-/g, '_');
|
||||
}
|
||||
|
||||
// return the updated keyword arguments
|
||||
options.dest = dest;
|
||||
options.optionStrings = optionStrings;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
||||
defaultValue = defaultValue || null;
|
||||
|
||||
var action = (options.action || defaultValue);
|
||||
delete options.action;
|
||||
|
||||
var actionClass = this._registryGet('action', action, action);
|
||||
return actionClass;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getHandler = function () {
|
||||
var handlerString = this.conflictHandler;
|
||||
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
||||
var func = this[handlerFuncName];
|
||||
if (typeof func === 'undefined') {
|
||||
var msg = 'invalid conflict resolution value: ' + handlerString;
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
return func;
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._checkConflict = function (action) {
|
||||
var optionStringActions = this._optionStringActions;
|
||||
var conflictOptionals = [];
|
||||
|
||||
// find all options that conflict with this option
|
||||
// collect pairs, the string, and an existing action that it conflicts with
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
var conflOptional = optionStringActions[optionString];
|
||||
if (typeof conflOptional !== 'undefined') {
|
||||
conflictOptionals.push([ optionString, conflOptional ]);
|
||||
}
|
||||
});
|
||||
|
||||
if (conflictOptionals.length > 0) {
|
||||
var conflictHandler = this._getHandler();
|
||||
conflictHandler.call(this, action, conflictOptionals);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
||||
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
||||
conflicts = conflicts.join(', ');
|
||||
throw argumentErrorHelper(
|
||||
action,
|
||||
format('Conflicting option string(s): %s', conflicts)
|
||||
);
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
||||
// remove all conflicting options
|
||||
var self = this;
|
||||
conflOptionals.forEach(function (pair) {
|
||||
var optionString = pair[0];
|
||||
var conflictingAction = pair[1];
|
||||
// remove the conflicting option string
|
||||
var i = conflictingAction.optionStrings.indexOf(optionString);
|
||||
if (i >= 0) {
|
||||
conflictingAction.optionStrings.splice(i, 1);
|
||||
}
|
||||
delete self._optionStringActions[optionString];
|
||||
// if the option now has no option string, remove it from the
|
||||
// container holding it
|
||||
if (conflictingAction.optionStrings.length === 0) {
|
||||
conflictingAction.container._removeAction(conflictingAction);
|
||||
}
|
||||
});
|
||||
};
|
14
bin/tags/node_modules/argparse/lib/argparse.js
generated
vendored
14
bin/tags/node_modules/argparse/lib/argparse.js
generated
vendored
@@ -1,14 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.ArgumentParser = require('./argument_parser.js');
|
||||
module.exports.Namespace = require('./namespace');
|
||||
module.exports.Action = require('./action');
|
||||
module.exports.HelpFormatter = require('./help/formatter.js');
|
||||
module.exports.Const = require('./const.js');
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter =
|
||||
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
|
||||
module.exports.RawDescriptionHelpFormatter =
|
||||
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
|
||||
module.exports.RawTextHelpFormatter =
|
||||
require('./help/added_formatters.js').RawTextHelpFormatter;
|
50
bin/tags/node_modules/argparse/lib/argument/error.js
generated
vendored
50
bin/tags/node_modules/argparse/lib/argument/error.js
generated
vendored
@@ -1,50 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var ERR_CODE = 'ARGError';
|
||||
|
||||
/*:nodoc:*
|
||||
* argumentError(argument, message) -> TypeError
|
||||
* - argument (Object): action with broken argument
|
||||
* - message (String): error message
|
||||
*
|
||||
* Error format helper. An error from creating or using an argument
|
||||
* (optional or positional). The string value of this exception
|
||||
* is the message, augmented with information
|
||||
* about the argument that caused it.
|
||||
*
|
||||
* #####Example
|
||||
*
|
||||
* var argumentErrorHelper = require('./argument/error');
|
||||
* if (conflictOptionals.length > 0) {
|
||||
* throw argumentErrorHelper(
|
||||
* action,
|
||||
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
|
||||
* );
|
||||
* }
|
||||
*
|
||||
**/
|
||||
module.exports = function (argument, message) {
|
||||
var argumentName = null;
|
||||
var errMessage;
|
||||
var err;
|
||||
|
||||
if (argument.getName) {
|
||||
argumentName = argument.getName();
|
||||
} else {
|
||||
argumentName = '' + argument;
|
||||
}
|
||||
|
||||
if (!argumentName) {
|
||||
errMessage = message;
|
||||
} else {
|
||||
errMessage = format('argument "%s": %s', argumentName, message);
|
||||
}
|
||||
|
||||
err = new TypeError(errMessage);
|
||||
err.code = ERR_CODE;
|
||||
return err;
|
||||
};
|
54
bin/tags/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
54
bin/tags/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
@@ -1,54 +0,0 @@
|
||||
/** internal
|
||||
* class MutuallyExclusiveGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ArgumentGroup = require('./group');
|
||||
|
||||
/**
|
||||
* new MutuallyExclusiveGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): options.required -> true/false
|
||||
*
|
||||
* `required` could be an argument itself, but making it a property of
|
||||
* the options argument is more consistent with the JS adaptation of the Python)
|
||||
**/
|
||||
var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
|
||||
var required;
|
||||
options = options || {};
|
||||
required = options.required || false;
|
||||
ArgumentGroup.call(this, container);
|
||||
this.required = required;
|
||||
|
||||
};
|
||||
util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._addAction = function (action) {
|
||||
var msg;
|
||||
if (action.required) {
|
||||
msg = 'mutually exclusive arguments must be optional';
|
||||
throw new Error(msg);
|
||||
}
|
||||
action = this._container._addAction(action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._removeAction = function (action) {
|
||||
this._container._removeAction(action);
|
||||
this._groupActions.remove(action);
|
||||
};
|
||||
|
75
bin/tags/node_modules/argparse/lib/argument/group.js
generated
vendored
75
bin/tags/node_modules/argparse/lib/argument/group.js
generated
vendored
@@ -1,75 +0,0 @@
|
||||
/** internal
|
||||
* class ArgumentGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionContainer = require('../action_container');
|
||||
|
||||
|
||||
/**
|
||||
* new ArgumentGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): hash of group options
|
||||
*
|
||||
* #### options
|
||||
* - **prefixChars** group name prefix
|
||||
* - **argumentDefault** default argument value
|
||||
* - **title** group title
|
||||
* - **description** group description
|
||||
*
|
||||
**/
|
||||
var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// add any missing keyword arguments by checking the container
|
||||
options.conflictHandler = (options.conflictHandler || container.conflictHandler);
|
||||
options.prefixChars = (options.prefixChars || container.prefixChars);
|
||||
options.argumentDefault = (options.argumentDefault || container.argumentDefault);
|
||||
|
||||
ActionContainer.call(this, options);
|
||||
|
||||
// group attributes
|
||||
this.title = options.title;
|
||||
this._groupActions = [];
|
||||
|
||||
// share most attributes with the container
|
||||
this._container = container;
|
||||
this._registries = container._registries;
|
||||
this._actions = container._actions;
|
||||
this._optionStringActions = container._optionStringActions;
|
||||
this._defaults = container._defaults;
|
||||
this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
|
||||
this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
|
||||
};
|
||||
util.inherits(ArgumentGroup, ActionContainer);
|
||||
|
||||
|
||||
ArgumentGroup.prototype._addAction = function (action) {
|
||||
// Parent add action
|
||||
action = ActionContainer.prototype._addAction.call(this, action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
ArgumentGroup.prototype._removeAction = function (action) {
|
||||
// Parent remove action
|
||||
ActionContainer.prototype._removeAction.call(this, action);
|
||||
var actionIndex = this._groupActions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._groupActions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
1161
bin/tags/node_modules/argparse/lib/argument_parser.js
generated
vendored
1161
bin/tags/node_modules/argparse/lib/argument_parser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
21
bin/tags/node_modules/argparse/lib/const.js
generated
vendored
21
bin/tags/node_modules/argparse/lib/const.js
generated
vendored
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports.EOL = '\n';
|
||||
|
||||
module.exports.SUPPRESS = '==SUPPRESS==';
|
||||
|
||||
module.exports.OPTIONAL = '?';
|
||||
|
||||
module.exports.ZERO_OR_MORE = '*';
|
||||
|
||||
module.exports.ONE_OR_MORE = '+';
|
||||
|
||||
module.exports.PARSER = 'A...';
|
||||
|
||||
module.exports.REMAINDER = '...';
|
||||
|
||||
module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
|
87
bin/tags/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
87
bin/tags/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
@@ -1,87 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
var HelpFormatter = require('./formatter.js');
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which adds default values to argument help.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function ArgumentDefaultsHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
|
||||
|
||||
ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
|
||||
var help = action.help;
|
||||
if (action.help.indexOf('%(defaultValue)s') === -1) {
|
||||
if (action.defaultValue !== c.SUPPRESS) {
|
||||
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
|
||||
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
|
||||
help += ' (default: %(defaultValue)s)';
|
||||
}
|
||||
}
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains any formatting in descriptions.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawDescriptionHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
|
||||
|
||||
RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = text.split('\n');
|
||||
lines = lines.map(function (line) {
|
||||
return $$.trimEnd(indent + line);
|
||||
});
|
||||
return lines.join('\n');
|
||||
};
|
||||
module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawTextHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains formatting of all help text.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawTextHelpFormatter(options) {
|
||||
RawDescriptionHelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
|
||||
|
||||
RawTextHelpFormatter.prototype._splitLines = function (text) {
|
||||
return text.split('\n');
|
||||
};
|
||||
|
||||
module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
|
795
bin/tags/node_modules/argparse/lib/help/formatter.js
generated
vendored
795
bin/tags/node_modules/argparse/lib/help/formatter.js
generated
vendored
@@ -1,795 +0,0 @@
|
||||
/**
|
||||
* class HelpFormatter
|
||||
*
|
||||
* Formatter for generating usage messages and argument help strings. Only the
|
||||
* name of this class is considered a public API. All the methods provided by
|
||||
* the class are considered an implementation detail.
|
||||
*
|
||||
* Do not call in your code, use this class only for inherits your own forvatter
|
||||
*
|
||||
* ToDo add [additonal formatters][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#formatter-class
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
|
||||
|
||||
/*:nodoc:* internal
|
||||
* new Support(parent, heding)
|
||||
* - parent (object): parent section
|
||||
* - heading (string): header string
|
||||
*
|
||||
**/
|
||||
function Section(parent, heading) {
|
||||
this._parent = parent;
|
||||
this._heading = heading;
|
||||
this._items = [];
|
||||
}
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#addItem(callback) -> Void
|
||||
* - callback (array): tuple with function and args
|
||||
*
|
||||
* Add function for single element
|
||||
**/
|
||||
Section.prototype.addItem = function (callback) {
|
||||
this._items.push(callback);
|
||||
};
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#formatHelp(formatter) -> string
|
||||
* - formatter (HelpFormatter): current formatter
|
||||
*
|
||||
* Form help section string
|
||||
*
|
||||
**/
|
||||
Section.prototype.formatHelp = function (formatter) {
|
||||
var itemHelp, heading;
|
||||
|
||||
// format the indented section
|
||||
if (this._parent) {
|
||||
formatter._indent();
|
||||
}
|
||||
|
||||
itemHelp = this._items.map(function (item) {
|
||||
var obj, func, args;
|
||||
|
||||
obj = formatter;
|
||||
func = item[0];
|
||||
args = item[1];
|
||||
return func.apply(obj, args);
|
||||
});
|
||||
itemHelp = formatter._joinParts(itemHelp);
|
||||
|
||||
if (this._parent) {
|
||||
formatter._dedent();
|
||||
}
|
||||
|
||||
// return nothing if the section was empty
|
||||
if (!itemHelp) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// add the heading if the section was non-empty
|
||||
heading = '';
|
||||
if (this._heading && this._heading !== c.SUPPRESS) {
|
||||
var currentIndent = formatter.currentIndent;
|
||||
heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;
|
||||
}
|
||||
|
||||
// join the section-initialize newline, the heading and the help
|
||||
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
|
||||
};
|
||||
|
||||
/**
|
||||
* new HelpFormatter(options)
|
||||
*
|
||||
* #### Options:
|
||||
* - `prog`: program name
|
||||
* - `indentIncriment`: indent step, default value 2
|
||||
* - `maxHelpPosition`: max help position, default value = 24
|
||||
* - `width`: line width
|
||||
*
|
||||
**/
|
||||
var HelpFormatter = module.exports = function HelpFormatter(options) {
|
||||
options = options || {};
|
||||
|
||||
this._prog = options.prog;
|
||||
|
||||
this._maxHelpPosition = options.maxHelpPosition || 24;
|
||||
this._width = (options.width || ((process.env.COLUMNS || 80) - 2));
|
||||
|
||||
this._currentIndent = 0;
|
||||
this._indentIncriment = options.indentIncriment || 2;
|
||||
this._level = 0;
|
||||
this._actionMaxLength = 0;
|
||||
|
||||
this._rootSection = new Section(null);
|
||||
this._currentSection = this._rootSection;
|
||||
|
||||
this._whitespaceMatcher = new RegExp('\\s+', 'g');
|
||||
this._longBreakMatcher = new RegExp(c.EOL + c.EOL + c.EOL + '+', 'g');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._indent = function () {
|
||||
this._currentIndent += this._indentIncriment;
|
||||
this._level += 1;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._dedent = function () {
|
||||
this._currentIndent -= this._indentIncriment;
|
||||
this._level -= 1;
|
||||
if (this._currentIndent < 0) {
|
||||
throw new Error('Indent decreased below 0.');
|
||||
}
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._addItem = function (func, args) {
|
||||
this._currentSection.addItem([ func, args ]);
|
||||
};
|
||||
|
||||
//
|
||||
// Message building methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#startSection(heading) -> Void
|
||||
* - heading (string): header string
|
||||
*
|
||||
* Start new help section
|
||||
*
|
||||
* See alse [code example][1]
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.startSection = function (heading) {
|
||||
this._indent();
|
||||
var section = new Section(this._currentSection, heading);
|
||||
var func = section.formatHelp.bind(section);
|
||||
this._addItem(func, [ this ]);
|
||||
this._currentSection = section;
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#endSection -> Void
|
||||
*
|
||||
* End help section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
**/
|
||||
HelpFormatter.prototype.endSection = function () {
|
||||
this._currentSection = this._currentSection._parent;
|
||||
this._dedent();
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addText(text) -> Void
|
||||
* - text (string): plain text
|
||||
*
|
||||
* Add plain text into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addText = function (text) {
|
||||
if (text && text !== c.SUPPRESS) {
|
||||
this._addItem(this._formatText, [ text ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addUsage(usage, actions, groups, prefix) -> Void
|
||||
* - usage (string): usage text
|
||||
* - actions (array): actions list
|
||||
* - groups (array): groups list
|
||||
* - prefix (string): usage prefix
|
||||
*
|
||||
* Add usage data into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addUsage(this.usage, this._actions, []);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {
|
||||
if (usage !== c.SUPPRESS) {
|
||||
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArgument(action) -> Void
|
||||
* - action (object): action
|
||||
*
|
||||
* Add argument into current section
|
||||
*
|
||||
* Single variant of [[HelpFormatter#addArguments]]
|
||||
**/
|
||||
HelpFormatter.prototype.addArgument = function (action) {
|
||||
if (action.help !== c.SUPPRESS) {
|
||||
var self = this;
|
||||
|
||||
// find all invocations
|
||||
var invocations = [ this._formatActionInvocation(action) ];
|
||||
var invocationLength = invocations[0].length;
|
||||
|
||||
var actionLength;
|
||||
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
|
||||
var invocationNew = self._formatActionInvocation(subaction);
|
||||
invocations.push(invocationNew);
|
||||
invocationLength = Math.max(invocationLength, invocationNew.length);
|
||||
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
|
||||
// update the maximum item length
|
||||
actionLength = invocationLength + this._currentIndent;
|
||||
this._actionMaxLength = Math.max(this._actionMaxLength, actionLength);
|
||||
|
||||
// add the item to the list
|
||||
this._addItem(this._formatAction, [ action ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArguments(actions) -> Void
|
||||
* - actions (array): actions list
|
||||
*
|
||||
* Mass add arguments into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addArguments = function (actions) {
|
||||
var self = this;
|
||||
actions.forEach(function (action) {
|
||||
self.addArgument(action);
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// Help-formatting methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#formatHelp -> string
|
||||
*
|
||||
* Format help
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addText(this.epilog);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.formatHelp = function () {
|
||||
var help = this._rootSection.formatHelp(this);
|
||||
if (help) {
|
||||
help = help.replace(this._longBreakMatcher, c.EOL + c.EOL);
|
||||
help = $$.trimChars(help, c.EOL) + c.EOL;
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._joinParts = function (partStrings) {
|
||||
return partStrings.filter(function (part) {
|
||||
return (part && part !== c.SUPPRESS);
|
||||
}).join('');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatUsage = function (usage, actions, groups, prefix) {
|
||||
if (!prefix && typeof prefix !== 'string') {
|
||||
prefix = 'usage: ';
|
||||
}
|
||||
|
||||
actions = actions || [];
|
||||
groups = groups || [];
|
||||
|
||||
|
||||
// if usage is specified, use that
|
||||
if (usage) {
|
||||
usage = sprintf(usage, { prog: this._prog });
|
||||
|
||||
// if no optionals or positionals are available, usage is just prog
|
||||
} else if (!usage && actions.length === 0) {
|
||||
usage = this._prog;
|
||||
|
||||
// if optionals and positionals are available, calculate usage
|
||||
} else if (!usage) {
|
||||
var prog = this._prog;
|
||||
var optionals = [];
|
||||
var positionals = [];
|
||||
var actionUsage;
|
||||
var textWidth;
|
||||
|
||||
// split optionals from positionals
|
||||
actions.forEach(function (action) {
|
||||
if (action.isOptional()) {
|
||||
optionals.push(action);
|
||||
} else {
|
||||
positionals.push(action);
|
||||
}
|
||||
});
|
||||
|
||||
// build full usage string
|
||||
actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
|
||||
usage = [ prog, actionUsage ].join(' ');
|
||||
|
||||
// wrap the usage parts if it's too long
|
||||
textWidth = this._width - this._currentIndent;
|
||||
if ((prefix.length + usage.length) > textWidth) {
|
||||
|
||||
// break usage into wrappable parts
|
||||
var regexpPart = new RegExp('\\(.*?\\)+|\\[.*?\\]+|\\S+', 'g');
|
||||
var optionalUsage = this._formatActionsUsage(optionals, groups);
|
||||
var positionalUsage = this._formatActionsUsage(positionals, groups);
|
||||
|
||||
|
||||
var optionalParts = optionalUsage.match(regexpPart);
|
||||
var positionalParts = positionalUsage.match(regexpPart) || [];
|
||||
|
||||
if (optionalParts.join(' ') !== optionalUsage) {
|
||||
throw new Error('assert "optionalParts.join(\' \') === optionalUsage"');
|
||||
}
|
||||
if (positionalParts.join(' ') !== positionalUsage) {
|
||||
throw new Error('assert "positionalParts.join(\' \') === positionalUsage"');
|
||||
}
|
||||
|
||||
// helper for wrapping lines
|
||||
/*eslint-disable func-style*/ // node 0.10 compat
|
||||
var _getLines = function (parts, indent, prefix) {
|
||||
var lines = [];
|
||||
var line = [];
|
||||
|
||||
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;
|
||||
|
||||
parts.forEach(function (part) {
|
||||
if (lineLength + 1 + part.length > textWidth) {
|
||||
lines.push(indent + line.join(' '));
|
||||
line = [];
|
||||
lineLength = indent.length - 1;
|
||||
}
|
||||
line.push(part);
|
||||
lineLength += part.length + 1;
|
||||
});
|
||||
|
||||
if (line) {
|
||||
lines.push(indent + line.join(' '));
|
||||
}
|
||||
if (prefix) {
|
||||
lines[0] = lines[0].substr(indent.length);
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
|
||||
var lines, indent, parts;
|
||||
// if prog is short, follow it with optionals or positionals
|
||||
if (prefix.length + prog.length <= 0.75 * textWidth) {
|
||||
indent = $$.repeat(' ', (prefix.length + prog.length + 1));
|
||||
if (optionalParts) {
|
||||
lines = [].concat(
|
||||
_getLines([ prog ].concat(optionalParts), indent, prefix),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
} else if (positionalParts) {
|
||||
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
|
||||
} else {
|
||||
lines = [ prog ];
|
||||
}
|
||||
|
||||
// if prog is long, put it on its own line
|
||||
} else {
|
||||
indent = $$.repeat(' ', prefix.length);
|
||||
parts = optionalParts.concat(positionalParts);
|
||||
lines = _getLines(parts, indent);
|
||||
if (lines.length > 1) {
|
||||
lines = [].concat(
|
||||
_getLines(optionalParts, indent),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
}
|
||||
lines = [ prog ].concat(lines);
|
||||
}
|
||||
// join lines into usage
|
||||
usage = lines.join(c.EOL);
|
||||
}
|
||||
}
|
||||
|
||||
// prefix with 'usage:'
|
||||
return prefix + usage + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionsUsage = function (actions, groups) {
|
||||
// find group indices and identify actions in groups
|
||||
var groupActions = [];
|
||||
var inserts = [];
|
||||
var self = this;
|
||||
|
||||
groups.forEach(function (group) {
|
||||
var end;
|
||||
var i;
|
||||
|
||||
var start = actions.indexOf(group._groupActions[0]);
|
||||
if (start >= 0) {
|
||||
end = start + group._groupActions.length;
|
||||
|
||||
//if (actions.slice(start, end) === group._groupActions) {
|
||||
if ($$.arrayEqual(actions.slice(start, end), group._groupActions)) {
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupActions.push(action);
|
||||
});
|
||||
|
||||
if (!group.required) {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' [';
|
||||
} else {
|
||||
inserts[start] = '[';
|
||||
}
|
||||
inserts[end] = ']';
|
||||
} else {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' (';
|
||||
} else {
|
||||
inserts[start] = '(';
|
||||
}
|
||||
inserts[end] = ')';
|
||||
}
|
||||
for (i = start + 1; i < end; i += 1) {
|
||||
inserts[i] = '|';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// collect all actions format strings
|
||||
var parts = [];
|
||||
|
||||
actions.forEach(function (action, actionIndex) {
|
||||
var part;
|
||||
var optionString;
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// suppressed arguments are marked with None
|
||||
// remove | separators for suppressed arguments
|
||||
if (action.help === c.SUPPRESS) {
|
||||
parts.push(null);
|
||||
if (inserts[actionIndex] === '|') {
|
||||
inserts.splice(actionIndex, actionIndex);
|
||||
} else if (inserts[actionIndex + 1] === '|') {
|
||||
inserts.splice(actionIndex + 1, actionIndex + 1);
|
||||
}
|
||||
|
||||
// produce all arg strings
|
||||
} else if (!action.isOptional()) {
|
||||
part = self._formatArgs(action, action.dest);
|
||||
|
||||
// if it's in a group, strip the outer []
|
||||
if (groupActions.indexOf(action) >= 0) {
|
||||
if (part[0] === '[' && part[part.length - 1] === ']') {
|
||||
part = part.slice(1, -1);
|
||||
}
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
|
||||
// produce the first way to invoke the option in brackets
|
||||
} else {
|
||||
optionString = action.optionStrings[0];
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s or --long
|
||||
if (action.nargs === 0) {
|
||||
part = '' + optionString;
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS or --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = self._formatArgs(action, argsDefault);
|
||||
part = optionString + ' ' + argsString;
|
||||
}
|
||||
// make it look optional if it's not required or in a group
|
||||
if (!action.required && groupActions.indexOf(action) < 0) {
|
||||
part = '[' + part + ']';
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
}
|
||||
});
|
||||
|
||||
// insert things at the necessary indices
|
||||
for (var i = inserts.length - 1; i >= 0; --i) {
|
||||
if (inserts[i] !== null) {
|
||||
parts.splice(i, 0, inserts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// join all the action items with spaces
|
||||
var text = parts.filter(function (part) {
|
||||
return !!part;
|
||||
}).join(' ');
|
||||
|
||||
// clean up separators for mutually exclusive groups
|
||||
text = text.replace(/([\[(]) /g, '$1'); // remove spaces
|
||||
text = text.replace(/ ([\])])/g, '$1');
|
||||
text = text.replace(/\[ *\]/g, ''); // remove empty groups
|
||||
text = text.replace(/\( *\)/g, '');
|
||||
text = text.replace(/\(([^|]*)\)/g, '$1'); // remove () from single action groups
|
||||
|
||||
text = text.trim();
|
||||
|
||||
// return the text
|
||||
return text;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatText = function (text) {
|
||||
text = sprintf(text, { prog: this._prog });
|
||||
var textWidth = this._width - this._currentIndent;
|
||||
var indentIncriment = $$.repeat(' ', this._currentIndent);
|
||||
return this._fillText(text, textWidth, indentIncriment) + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
var helpText;
|
||||
var helpLines;
|
||||
var parts;
|
||||
var indentFirst;
|
||||
|
||||
// determine the required width and the entry label
|
||||
var helpPosition = Math.min(this._actionMaxLength + 2, this._maxHelpPosition);
|
||||
var helpWidth = this._width - helpPosition;
|
||||
var actionWidth = helpPosition - this._currentIndent - 2;
|
||||
var actionHeader = this._formatActionInvocation(action);
|
||||
|
||||
// no help; start on same line and add a final newline
|
||||
if (!action.help) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
|
||||
// short action name; start on the same line and pad two spaces
|
||||
} else if (actionHeader.length <= actionWidth) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) +
|
||||
actionHeader +
|
||||
' ' +
|
||||
$$.repeat(' ', actionWidth - actionHeader.length);
|
||||
indentFirst = 0;
|
||||
|
||||
// long action name; start on the next line
|
||||
} else {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
indentFirst = helpPosition;
|
||||
}
|
||||
|
||||
// collect the pieces of the action help
|
||||
parts = [ actionHeader ];
|
||||
|
||||
// if there was help for the action, add lines of help text
|
||||
if (action.help) {
|
||||
helpText = this._expandHelp(action);
|
||||
helpLines = this._splitLines(helpText, helpWidth);
|
||||
parts.push($$.repeat(' ', indentFirst) + helpLines[0] + c.EOL);
|
||||
helpLines.slice(1).forEach(function (line) {
|
||||
parts.push($$.repeat(' ', helpPosition) + line + c.EOL);
|
||||
});
|
||||
|
||||
// or add a newline if the description doesn't end with one
|
||||
} else if (actionHeader.charAt(actionHeader.length - 1) !== c.EOL) {
|
||||
parts.push(c.EOL);
|
||||
}
|
||||
// if there are any sub-actions, add their help as well
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
parts.push(self._formatAction(subaction));
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
// return a single string
|
||||
return this._joinParts(parts);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionInvocation = function (action) {
|
||||
if (!action.isOptional()) {
|
||||
var format_func = this._metavarFormatter(action, action.dest);
|
||||
var metavars = format_func(1);
|
||||
return metavars[0];
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s, --long
|
||||
if (action.nargs === 0) {
|
||||
parts = parts.concat(action.optionStrings);
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS, --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = this._formatArgs(action, argsDefault);
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
parts.push(optionString + ' ' + argsString);
|
||||
});
|
||||
}
|
||||
return parts.join(', ');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._metavarFormatter = function (action, metavarDefault) {
|
||||
var result;
|
||||
|
||||
if (action.metavar || action.metavar === '') {
|
||||
result = action.metavar;
|
||||
} else if (action.choices) {
|
||||
var choices = action.choices;
|
||||
|
||||
if (typeof choices === 'string') {
|
||||
choices = choices.split('').join(', ');
|
||||
} else if (Array.isArray(choices)) {
|
||||
choices = choices.join(',');
|
||||
} else {
|
||||
choices = Object.keys(choices).join(',');
|
||||
}
|
||||
result = '{' + choices + '}';
|
||||
} else {
|
||||
result = metavarDefault;
|
||||
}
|
||||
|
||||
return function (size) {
|
||||
if (Array.isArray(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var metavars = [];
|
||||
for (var i = 0; i < size; i += 1) {
|
||||
metavars.push(result);
|
||||
}
|
||||
return metavars;
|
||||
};
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatArgs = function (action, metavarDefault) {
|
||||
var result;
|
||||
var metavars;
|
||||
|
||||
var buildMetavar = this._metavarFormatter(action, metavarDefault);
|
||||
|
||||
switch (action.nargs) {
|
||||
/*eslint-disable no-undefined*/
|
||||
case undefined:
|
||||
case null:
|
||||
metavars = buildMetavar(1);
|
||||
result = '' + metavars[0];
|
||||
break;
|
||||
case c.OPTIONAL:
|
||||
metavars = buildMetavar(1);
|
||||
result = '[' + metavars[0] + ']';
|
||||
break;
|
||||
case c.ZERO_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '[' + metavars[0] + ' [' + metavars[1] + ' ...]]';
|
||||
break;
|
||||
case c.ONE_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '' + metavars[0] + ' [' + metavars[1] + ' ...]';
|
||||
break;
|
||||
case c.REMAINDER:
|
||||
result = '...';
|
||||
break;
|
||||
case c.PARSER:
|
||||
metavars = buildMetavar(1);
|
||||
result = metavars[0] + ' ...';
|
||||
break;
|
||||
default:
|
||||
metavars = buildMetavar(action.nargs);
|
||||
result = metavars.join(' ');
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._expandHelp = function (action) {
|
||||
var params = { prog: this._prog };
|
||||
|
||||
Object.keys(action).forEach(function (actionProperty) {
|
||||
var actionValue = action[actionProperty];
|
||||
|
||||
if (actionValue !== c.SUPPRESS) {
|
||||
params[actionProperty] = actionValue;
|
||||
}
|
||||
});
|
||||
|
||||
if (params.choices) {
|
||||
if (typeof params.choices === 'string') {
|
||||
params.choices = params.choices.split('').join(', ');
|
||||
} else if (Array.isArray(params.choices)) {
|
||||
params.choices = params.choices.join(', ');
|
||||
} else {
|
||||
params.choices = Object.keys(params.choices).join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(this._getHelpString(action), params);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._splitLines = function (text, width) {
|
||||
var lines = [];
|
||||
var delimiters = [ ' ', '.', ',', '!', '?' ];
|
||||
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
|
||||
|
||||
text = text.replace(/[\n\|\t]/g, ' ');
|
||||
|
||||
text = text.trim();
|
||||
text = text.replace(this._whitespaceMatcher, ' ');
|
||||
|
||||
// Wraps the single paragraph in text (a string) so every line
|
||||
// is at most width characters long.
|
||||
text.split(c.EOL).forEach(function (line) {
|
||||
if (width >= line.length) {
|
||||
lines.push(line);
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapStart = 0;
|
||||
var wrapEnd = width;
|
||||
var delimiterIndex = 0;
|
||||
while (wrapEnd <= line.length) {
|
||||
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
|
||||
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
|
||||
wrapEnd = wrapStart + delimiterIndex + 1;
|
||||
}
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
wrapStart = wrapEnd;
|
||||
wrapEnd += width;
|
||||
}
|
||||
if (wrapStart < line.length) {
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
}
|
||||
});
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = this._splitLines(text, width);
|
||||
lines = lines.map(function (line) {
|
||||
return indent + line;
|
||||
});
|
||||
return lines.join(c.EOL);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._getHelpString = function (action) {
|
||||
return action.help;
|
||||
};
|
76
bin/tags/node_modules/argparse/lib/namespace.js
generated
vendored
76
bin/tags/node_modules/argparse/lib/namespace.js
generated
vendored
@@ -1,76 +0,0 @@
|
||||
/**
|
||||
* class Namespace
|
||||
*
|
||||
* Simple object for storing attributes. Implements equality by attribute names
|
||||
* and values, and provides a simple string representation.
|
||||
*
|
||||
* See also [original guide][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
/**
|
||||
* new Namespace(options)
|
||||
* - options(object): predefined propertis for result object
|
||||
*
|
||||
**/
|
||||
var Namespace = module.exports = function Namespace(options) {
|
||||
$$.extend(this, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#isset(key) -> Boolean
|
||||
* - key (string|number): property name
|
||||
*
|
||||
* Tells whenever `namespace` contains given `key` or not.
|
||||
**/
|
||||
Namespace.prototype.isset = function (key) {
|
||||
return $$.has(this, key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#set(key, value) -> self
|
||||
* -key (string|number|object): propery name
|
||||
* -value (mixed): new property value
|
||||
*
|
||||
* Set the property named key with value.
|
||||
* If key object then set all key properties to namespace object
|
||||
**/
|
||||
Namespace.prototype.set = function (key, value) {
|
||||
if (typeof (key) === 'object') {
|
||||
$$.extend(this, key);
|
||||
} else {
|
||||
this[key] = value;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#get(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return the property key or defaulValue if not set
|
||||
**/
|
||||
Namespace.prototype.get = function (key, defaultValue) {
|
||||
return !this[key] ? defaultValue : this[key];
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#unset(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return data[key](and delete it) or defaultValue
|
||||
**/
|
||||
Namespace.prototype.unset = function (key, defaultValue) {
|
||||
var value = this[key];
|
||||
if (value !== null) {
|
||||
delete this[key];
|
||||
return value;
|
||||
}
|
||||
return defaultValue;
|
||||
};
|
57
bin/tags/node_modules/argparse/lib/utils.js
generated
vendored
57
bin/tags/node_modules/argparse/lib/utils.js
generated
vendored
@@ -1,57 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
exports.repeat = function (str, num) {
|
||||
var result = '';
|
||||
for (var i = 0; i < num; i++) { result += str; }
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.arrayEqual = function (a, b) {
|
||||
if (a.length !== b.length) { return false; }
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) { return false; }
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.trimChars = function (str, chars) {
|
||||
var start = 0;
|
||||
var end = str.length - 1;
|
||||
while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
|
||||
while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
|
||||
return str.slice(start, end + 1);
|
||||
};
|
||||
|
||||
exports.capitalize = function (str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
exports.arrayUnion = function () {
|
||||
var result = [];
|
||||
for (var i = 0, values = {}; i < arguments.length; i++) {
|
||||
var arr = arguments[i];
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
if (!values[arr[j]]) {
|
||||
values[arr[j]] = true;
|
||||
result.push(arr[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function has(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
exports.has = has;
|
||||
|
||||
exports.extend = function (dest, src) {
|
||||
for (var i in src) {
|
||||
if (has(src, i)) { dest[i] = src[i]; }
|
||||
}
|
||||
};
|
||||
|
||||
exports.trimEnd = function (str) {
|
||||
return str.replace(/\s+$/g, '');
|
||||
};
|
70
bin/tags/node_modules/argparse/package.json
generated
vendored
70
bin/tags/node_modules/argparse/package.json
generated
vendored
@@ -1,70 +0,0 @@
|
||||
{
|
||||
"_from": "argparse@^1.0.7",
|
||||
"_id": "argparse@1.0.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"_location": "/argparse",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "argparse@^1.0.7",
|
||||
"name": "argparse",
|
||||
"escapedName": "argparse",
|
||||
"rawSpec": "^1.0.7",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.7"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/js-yaml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"_shasum": "bcd6791ea5ae09725e17e5ad988134cd40b3d911",
|
||||
"_spec": "argparse@^1.0.7",
|
||||
"_where": "/home/ryan/Documents/node_modules/js-yaml",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodeca/argparse/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Eugene Shkuropat"
|
||||
},
|
||||
{
|
||||
"name": "Paul Jacobson"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/argparse#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
"argparse",
|
||||
"option",
|
||||
"args"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "argparse",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nodeca/argparse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.10"
|
||||
}
|
5
bin/tags/node_modules/balanced-match/.npmignore
generated
vendored
5
bin/tags/node_modules/balanced-match/.npmignore
generated
vendored
@@ -1,5 +0,0 @@
|
||||
test
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Makefile
|
||||
example.js
|
21
bin/tags/node_modules/balanced-match/LICENSE.md
generated
vendored
21
bin/tags/node_modules/balanced-match/LICENSE.md
generated
vendored
@@ -1,21 +0,0 @@
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
91
bin/tags/node_modules/balanced-match/README.md
generated
vendored
91
bin/tags/node_modules/balanced-match/README.md
generated
vendored
@@ -1,91 +0,0 @@
|
||||
# balanced-match
|
||||
|
||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||
|
||||
[](http://travis-ci.org/juliangruber/balanced-match)
|
||||
[](https://www.npmjs.org/package/balanced-match)
|
||||
|
||||
[](https://ci.testling.com/juliangruber/balanced-match)
|
||||
|
||||
## Example
|
||||
|
||||
Get the first matching pair of braces:
|
||||
|
||||
```js
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
||||
```
|
||||
|
||||
The matches are:
|
||||
|
||||
```bash
|
||||
$ node example.js
|
||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
||||
{ start: 3,
|
||||
end: 9,
|
||||
pre: 'pre',
|
||||
body: 'first',
|
||||
post: 'between{second}post' }
|
||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### var m = balanced(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
object with those keys:
|
||||
|
||||
* **start** the index of the first match of `a`
|
||||
* **end** the index of the matching `b`
|
||||
* **pre** the preamble, `a` and `b` not included
|
||||
* **body** the match, `a` and `b` not included
|
||||
* **post** the postscript, `a` and `b` not included
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
||||
|
||||
### var r = balanced.range(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
array with indexes: `[ <a index>, <b index> ]`.
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install balanced-match
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
59
bin/tags/node_modules/balanced-match/index.js
generated
vendored
59
bin/tags/node_modules/balanced-match/index.js
generated
vendored
@@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
module.exports = balanced;
|
||||
function balanced(a, b, str) {
|
||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||
|
||||
var r = range(a, b, str);
|
||||
|
||||
return r && {
|
||||
start: r[0],
|
||||
end: r[1],
|
||||
pre: str.slice(0, r[0]),
|
||||
body: str.slice(r[0] + a.length, r[1]),
|
||||
post: str.slice(r[1] + b.length)
|
||||
};
|
||||
}
|
||||
|
||||
function maybeMatch(reg, str) {
|
||||
var m = str.match(reg);
|
||||
return m ? m[0] : null;
|
||||
}
|
||||
|
||||
balanced.range = range;
|
||||
function range(a, b, str) {
|
||||
var begs, beg, left, right, result;
|
||||
var ai = str.indexOf(a);
|
||||
var bi = str.indexOf(b, ai + 1);
|
||||
var i = ai;
|
||||
|
||||
if (ai >= 0 && bi > 0) {
|
||||
begs = [];
|
||||
left = str.length;
|
||||
|
||||
while (i >= 0 && !result) {
|
||||
if (i == ai) {
|
||||
begs.push(i);
|
||||
ai = str.indexOf(a, i + 1);
|
||||
} else if (begs.length == 1) {
|
||||
result = [ begs.pop(), bi ];
|
||||
} else {
|
||||
beg = begs.pop();
|
||||
if (beg < left) {
|
||||
left = beg;
|
||||
right = bi;
|
||||
}
|
||||
|
||||
bi = str.indexOf(b, i + 1);
|
||||
}
|
||||
|
||||
i = ai < bi && ai >= 0 ? ai : bi;
|
||||
}
|
||||
|
||||
if (begs.length) {
|
||||
result = [ left, right ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
77
bin/tags/node_modules/balanced-match/package.json
generated
vendored
77
bin/tags/node_modules/balanced-match/package.json
generated
vendored
@@ -1,77 +0,0 @@
|
||||
{
|
||||
"_from": "balanced-match@^1.0.0",
|
||||
"_id": "balanced-match@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"_location": "/balanced-match",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "balanced-match@^1.0.0",
|
||||
"name": "balanced-match",
|
||||
"escapedName": "balanced-match",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/brace-expansion"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||
"_spec": "balanced-match@^1.0.0",
|
||||
"_where": "/home/ryan/Documents/node_modules/brace-expansion",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/balanced-match/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||
"keywords": [
|
||||
"match",
|
||||
"regexp",
|
||||
"test",
|
||||
"balanced",
|
||||
"parse"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "balanced-match",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "make bench",
|
||||
"test": "make test"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
21
bin/tags/node_modules/brace-expansion/LICENSE
generated
vendored
21
bin/tags/node_modules/brace-expansion/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
129
bin/tags/node_modules/brace-expansion/README.md
generated
vendored
129
bin/tags/node_modules/brace-expansion/README.md
generated
vendored
@@ -1,129 +0,0 @@
|
||||
# brace-expansion
|
||||
|
||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
||||
as known from sh/bash, in JavaScript.
|
||||
|
||||
[](http://travis-ci.org/juliangruber/brace-expansion)
|
||||
[](https://www.npmjs.org/package/brace-expansion)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
[](https://ci.testling.com/juliangruber/brace-expansion)
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
|
||||
expand('file-{a,b,c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('-v{,,}')
|
||||
// => ['-v', '-v', '-v']
|
||||
|
||||
expand('file{0..2}.jpg')
|
||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
||||
|
||||
expand('file-{a..c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('file{2..0}.jpg')
|
||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
||||
|
||||
expand('file{0..4..2}.jpg')
|
||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
||||
|
||||
expand('file-{a..e..2}.jpg')
|
||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
||||
|
||||
expand('file{00..10..5}.jpg')
|
||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
||||
|
||||
expand('{{A..C},{a..c}}')
|
||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
||||
|
||||
expand('ppp{,config,oe{,conf}}')
|
||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
```
|
||||
|
||||
### var expanded = expand(str)
|
||||
|
||||
Return an array of all possible and valid expansions of `str`. If none are
|
||||
found, `[str]` is returned.
|
||||
|
||||
Valid expansions are:
|
||||
|
||||
```js
|
||||
/^(.*,)+(.+)?$/
|
||||
// {a,b,...}
|
||||
```
|
||||
|
||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
||||
to have equal length. Negative numbers and backwards iteration work too.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
||||
number.
|
||||
|
||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install brace-expansion
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Julian Gruber](https://github.com/juliangruber)
|
||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
||||
|
||||
## Sponsors
|
||||
|
||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
||||
|
||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
201
bin/tags/node_modules/brace-expansion/index.js
generated
vendored
201
bin/tags/node_modules/brace-expansion/index.js
generated
vendored
@@ -1,201 +0,0 @@
|
||||
var concatMap = require('concat-map');
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
module.exports = expandTop;
|
||||
|
||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
||||
|
||||
function numeric(str) {
|
||||
return parseInt(str, 10) == str
|
||||
? parseInt(str, 10)
|
||||
: str.charCodeAt(0);
|
||||
}
|
||||
|
||||
function escapeBraces(str) {
|
||||
return str.split('\\\\').join(escSlash)
|
||||
.split('\\{').join(escOpen)
|
||||
.split('\\}').join(escClose)
|
||||
.split('\\,').join(escComma)
|
||||
.split('\\.').join(escPeriod);
|
||||
}
|
||||
|
||||
function unescapeBraces(str) {
|
||||
return str.split(escSlash).join('\\')
|
||||
.split(escOpen).join('{')
|
||||
.split(escClose).join('}')
|
||||
.split(escComma).join(',')
|
||||
.split(escPeriod).join('.');
|
||||
}
|
||||
|
||||
|
||||
// Basically just str.split(","), but handling cases
|
||||
// where we have nested braced sections, which should be
|
||||
// treated as individual members, like {a,{b,c},d}
|
||||
function parseCommaParts(str) {
|
||||
if (!str)
|
||||
return [''];
|
||||
|
||||
var parts = [];
|
||||
var m = balanced('{', '}', str);
|
||||
|
||||
if (!m)
|
||||
return str.split(',');
|
||||
|
||||
var pre = m.pre;
|
||||
var body = m.body;
|
||||
var post = m.post;
|
||||
var p = pre.split(',');
|
||||
|
||||
p[p.length-1] += '{' + body + '}';
|
||||
var postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
p[p.length-1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
|
||||
parts.push.apply(parts, p);
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
function expandTop(str) {
|
||||
if (!str)
|
||||
return [];
|
||||
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
// but a{},b}c will be expanded to [a}c,abc].
|
||||
// One could argue that this is a bug in Bash, but since the goal of
|
||||
// this module is to match Bash's rules, we escape a leading {}
|
||||
if (str.substr(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.substr(2);
|
||||
}
|
||||
|
||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||
}
|
||||
|
||||
function identity(e) {
|
||||
return e;
|
||||
}
|
||||
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
}
|
||||
function isPadded(el) {
|
||||
return /^-?0\d/.test(el);
|
||||
}
|
||||
|
||||
function lte(i, y) {
|
||||
return i <= y;
|
||||
}
|
||||
function gte(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
|
||||
function expand(str, isTop) {
|
||||
var expansions = [];
|
||||
|
||||
var m = balanced('{', '}', str);
|
||||
if (!m || /\$$/.test(m.pre)) return [str];
|
||||
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isSequence = isNumericSequence || isAlphaSequence;
|
||||
var isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,.*\}/)) {
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
return expand(str);
|
||||
}
|
||||
return [str];
|
||||
}
|
||||
|
||||
var n;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand(n[0], false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, n is the parts, and we know it's not a comma set
|
||||
// with a single entry.
|
||||
|
||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||
var pre = m.pre;
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
|
||||
var N;
|
||||
|
||||
if (isSequence) {
|
||||
var x = numeric(n[0]);
|
||||
var y = numeric(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length)
|
||||
var incr = n.length == 3
|
||||
? Math.abs(numeric(n[2]))
|
||||
: 1;
|
||||
var test = lte;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte;
|
||||
}
|
||||
var pad = n.some(isPadded);
|
||||
|
||||
N = [];
|
||||
|
||||
for (var i = x; test(i, y); i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === '\\')
|
||||
c = '';
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join('0');
|
||||
if (i < 0)
|
||||
c = '-' + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) { return expand(el, false) });
|
||||
}
|
||||
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
|
||||
return expansions;
|
||||
}
|
||||
|
75
bin/tags/node_modules/brace-expansion/package.json
generated
vendored
75
bin/tags/node_modules/brace-expansion/package.json
generated
vendored
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"_from": "brace-expansion@^1.1.7",
|
||||
"_id": "brace-expansion@1.1.11",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"_location": "/brace-expansion",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "brace-expansion@^1.1.7",
|
||||
"name": "brace-expansion",
|
||||
"escapedName": "brace-expansion",
|
||||
"rawSpec": "^1.1.7",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.7"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/minimatch"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"_shasum": "3c7fcbf529d87226f3d2f52b966ff5271eb441dd",
|
||||
"_spec": "brace-expansion@^1.1.7",
|
||||
"_where": "/home/ryan/Documents/node_modules/minimatch",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/brace-expansion/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Brace expansion as known from sh/bash",
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "brace-expansion",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "matcha test/perf/bench.js",
|
||||
"gentest": "bash test/generate.sh",
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.1.11"
|
||||
}
|
419
bin/tags/node_modules/commander/CHANGELOG.md
generated
vendored
419
bin/tags/node_modules/commander/CHANGELOG.md
generated
vendored
@@ -1,419 +0,0 @@
|
||||
2.20.3 / 2019-10-11
|
||||
==================
|
||||
|
||||
* Support Node.js 0.10 (Revert #1059)
|
||||
* Ran "npm unpublish commander@2.20.2". There is no 2.20.2.
|
||||
|
||||
2.20.1 / 2019-09-29
|
||||
==================
|
||||
|
||||
* Improve executable subcommand tracking
|
||||
* Update dev dependencies
|
||||
|
||||
2.20.0 / 2019-04-02
|
||||
==================
|
||||
|
||||
* fix: resolve symbolic links completely when hunting for subcommands (#935)
|
||||
* Update index.d.ts (#930)
|
||||
* Update Readme.md (#924)
|
||||
* Remove --save option as it isn't required anymore (#918)
|
||||
* Add link to the license file (#900)
|
||||
* Added example of receiving args from options (#858)
|
||||
* Added missing semicolon (#882)
|
||||
* Add extension to .eslintrc (#876)
|
||||
|
||||
2.19.0 / 2018-10-02
|
||||
==================
|
||||
|
||||
* Removed newline after Options and Commands headers (#864)
|
||||
* Bugfix - Error output (#862)
|
||||
* Fix to change default value to string (#856)
|
||||
|
||||
2.18.0 / 2018-09-07
|
||||
==================
|
||||
|
||||
* Standardize help output (#853)
|
||||
* chmod 644 travis.yml (#851)
|
||||
* add support for execute typescript subcommand via ts-node (#849)
|
||||
|
||||
2.17.1 / 2018-08-07
|
||||
==================
|
||||
|
||||
* Fix bug in command emit (#844)
|
||||
|
||||
2.17.0 / 2018-08-03
|
||||
==================
|
||||
|
||||
* fixed newline output after help information (#833)
|
||||
* Fix to emit the action even without command (#778)
|
||||
* npm update (#823)
|
||||
|
||||
2.16.0 / 2018-06-29
|
||||
==================
|
||||
|
||||
* Remove Makefile and `test/run` (#821)
|
||||
* Make 'npm test' run on Windows (#820)
|
||||
* Add badge to display install size (#807)
|
||||
* chore: cache node_modules (#814)
|
||||
* chore: remove Node.js 4 (EOL), add Node.js 10 (#813)
|
||||
* fixed typo in readme (#812)
|
||||
* Fix types (#804)
|
||||
* Update eslint to resolve vulnerabilities in lodash (#799)
|
||||
* updated readme with custom event listeners. (#791)
|
||||
* fix tests (#794)
|
||||
|
||||
2.15.0 / 2018-03-07
|
||||
==================
|
||||
|
||||
* Update downloads badge to point to graph of downloads over time instead of duplicating link to npm
|
||||
* Arguments description
|
||||
|
||||
2.14.1 / 2018-02-07
|
||||
==================
|
||||
|
||||
* Fix typing of help function
|
||||
|
||||
2.14.0 / 2018-02-05
|
||||
==================
|
||||
|
||||
* only register the option:version event once
|
||||
* Fixes issue #727: Passing empty string for option on command is set to undefined
|
||||
* enable eqeqeq rule
|
||||
* resolves #754 add linter configuration to project
|
||||
* resolves #560 respect custom name for version option
|
||||
* document how to override the version flag
|
||||
* document using options per command
|
||||
|
||||
2.13.0 / 2018-01-09
|
||||
==================
|
||||
|
||||
* Do not print default for --no-
|
||||
* remove trailing spaces in command help
|
||||
* Update CI's Node.js to LTS and latest version
|
||||
* typedefs: Command and Option types added to commander namespace
|
||||
|
||||
2.12.2 / 2017-11-28
|
||||
==================
|
||||
|
||||
* fix: typings are not shipped
|
||||
|
||||
2.12.1 / 2017-11-23
|
||||
==================
|
||||
|
||||
* Move @types/node to dev dependency
|
||||
|
||||
2.12.0 / 2017-11-22
|
||||
==================
|
||||
|
||||
* add attributeName() method to Option objects
|
||||
* Documentation updated for options with --no prefix
|
||||
* typings: `outputHelp` takes a string as the first parameter
|
||||
* typings: use overloads
|
||||
* feat(typings): update to match js api
|
||||
* Print default value in option help
|
||||
* Fix translation error
|
||||
* Fail when using same command and alias (#491)
|
||||
* feat(typings): add help callback
|
||||
* fix bug when description is add after command with options (#662)
|
||||
* Format js code
|
||||
* Rename History.md to CHANGELOG.md (#668)
|
||||
* feat(typings): add typings to support TypeScript (#646)
|
||||
* use current node
|
||||
|
||||
2.11.0 / 2017-07-03
|
||||
==================
|
||||
|
||||
* Fix help section order and padding (#652)
|
||||
* feature: support for signals to subcommands (#632)
|
||||
* Fixed #37, --help should not display first (#447)
|
||||
* Fix translation errors. (#570)
|
||||
* Add package-lock.json
|
||||
* Remove engines
|
||||
* Upgrade package version
|
||||
* Prefix events to prevent conflicts between commands and options (#494)
|
||||
* Removing dependency on graceful-readlink
|
||||
* Support setting name in #name function and make it chainable
|
||||
* Add .vscode directory to .gitignore (Visual Studio Code metadata)
|
||||
* Updated link to ruby commander in readme files
|
||||
|
||||
2.10.0 / 2017-06-19
|
||||
==================
|
||||
|
||||
* Update .travis.yml. drop support for older node.js versions.
|
||||
* Fix require arguments in README.md
|
||||
* On SemVer you do not start from 0.0.1
|
||||
* Add missing semi colon in readme
|
||||
* Add save param to npm install
|
||||
* node v6 travis test
|
||||
* Update Readme_zh-CN.md
|
||||
* Allow literal '--' to be passed-through as an argument
|
||||
* Test subcommand alias help
|
||||
* link build badge to master branch
|
||||
* Support the alias of Git style sub-command
|
||||
* added keyword commander for better search result on npm
|
||||
* Fix Sub-Subcommands
|
||||
* test node.js stable
|
||||
* Fixes TypeError when a command has an option called `--description`
|
||||
* Update README.md to make it beginner friendly and elaborate on the difference between angled and square brackets.
|
||||
* Add chinese Readme file
|
||||
|
||||
2.9.0 / 2015-10-13
|
||||
==================
|
||||
|
||||
* Add option `isDefault` to set default subcommand #415 @Qix-
|
||||
* Add callback to allow filtering or post-processing of help text #434 @djulien
|
||||
* Fix `undefined` text in help information close #414 #416 @zhiyelee
|
||||
|
||||
2.8.1 / 2015-04-22
|
||||
==================
|
||||
|
||||
* Back out `support multiline description` Close #396 #397
|
||||
|
||||
2.8.0 / 2015-04-07
|
||||
==================
|
||||
|
||||
* Add `process.execArg` support, execution args like `--harmony` will be passed to sub-commands #387 @DigitalIO @zhiyelee
|
||||
* Fix bug in Git-style sub-commands #372 @zhiyelee
|
||||
* Allow commands to be hidden from help #383 @tonylukasavage
|
||||
* When git-style sub-commands are in use, yet none are called, display help #382 @claylo
|
||||
* Add ability to specify arguments syntax for top-level command #258 @rrthomas
|
||||
* Support multiline descriptions #208 @zxqfox
|
||||
|
||||
2.7.1 / 2015-03-11
|
||||
==================
|
||||
|
||||
* Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367.
|
||||
|
||||
2.7.0 / 2015-03-09
|
||||
==================
|
||||
|
||||
* Fix git-style bug when installed globally. Close #335 #349 @zhiyelee
|
||||
* Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage
|
||||
* Add support for camelCase on `opts()`. Close #353 @nkzawa
|
||||
* Add node.js 0.12 and io.js to travis.yml
|
||||
* Allow RegEx options. #337 @palanik
|
||||
* Fixes exit code when sub-command failing. Close #260 #332 @pirelenito
|
||||
* git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee
|
||||
|
||||
2.6.0 / 2014-12-30
|
||||
==================
|
||||
|
||||
* added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
|
||||
* Add application description to the help msg. Close #112 @dalssoft
|
||||
|
||||
2.5.1 / 2014-12-15
|
||||
==================
|
||||
|
||||
* fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
|
||||
|
||||
2.5.0 / 2014-10-24
|
||||
==================
|
||||
|
||||
* add support for variadic arguments. Closes #277 @whitlockjc
|
||||
|
||||
2.4.0 / 2014-10-17
|
||||
==================
|
||||
|
||||
* fixed a bug on executing the coercion function of subcommands option. Closes #270
|
||||
* added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
|
||||
* added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
|
||||
* fixed a bug on subcommand name. Closes #248 @jonathandelgado
|
||||
* fixed function normalize doesn’t honor option terminator. Closes #216 @abbr
|
||||
|
||||
2.3.0 / 2014-07-16
|
||||
==================
|
||||
|
||||
* add command alias'. Closes PR #210
|
||||
* fix: Typos. Closes #99
|
||||
* fix: Unused fs module. Closes #217
|
||||
|
||||
2.2.0 / 2014-03-29
|
||||
==================
|
||||
|
||||
* add passing of previous option value
|
||||
* fix: support subcommands on windows. Closes #142
|
||||
* Now the defaultValue passed as the second argument of the coercion function.
|
||||
|
||||
2.1.0 / 2013-11-21
|
||||
==================
|
||||
|
||||
* add: allow cflag style option params, unit test, fixes #174
|
||||
|
||||
2.0.0 / 2013-07-18
|
||||
==================
|
||||
|
||||
* remove input methods (.prompt, .confirm, etc)
|
||||
|
||||
1.3.2 / 2013-07-18
|
||||
==================
|
||||
|
||||
* add support for sub-commands to co-exist with the original command
|
||||
|
||||
1.3.1 / 2013-07-18
|
||||
==================
|
||||
|
||||
* add quick .runningCommand hack so you can opt-out of other logic when running a sub command
|
||||
|
||||
1.3.0 / 2013-07-09
|
||||
==================
|
||||
|
||||
* add EACCES error handling
|
||||
* fix sub-command --help
|
||||
|
||||
1.2.0 / 2013-06-13
|
||||
==================
|
||||
|
||||
* allow "-" hyphen as an option argument
|
||||
* support for RegExp coercion
|
||||
|
||||
1.1.1 / 2012-11-20
|
||||
==================
|
||||
|
||||
* add more sub-command padding
|
||||
* fix .usage() when args are present. Closes #106
|
||||
|
||||
1.1.0 / 2012-11-16
|
||||
==================
|
||||
|
||||
* add git-style executable subcommand support. Closes #94
|
||||
|
||||
1.0.5 / 2012-10-09
|
||||
==================
|
||||
|
||||
* fix `--name` clobbering. Closes #92
|
||||
* fix examples/help. Closes #89
|
||||
|
||||
1.0.4 / 2012-09-03
|
||||
==================
|
||||
|
||||
* add `outputHelp()` method.
|
||||
|
||||
1.0.3 / 2012-08-30
|
||||
==================
|
||||
|
||||
* remove invalid .version() defaulting
|
||||
|
||||
1.0.2 / 2012-08-24
|
||||
==================
|
||||
|
||||
* add `--foo=bar` support [arv]
|
||||
* fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
|
||||
|
||||
1.0.1 / 2012-08-03
|
||||
==================
|
||||
|
||||
* fix issue #56
|
||||
* fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
|
||||
|
||||
1.0.0 / 2012-07-05
|
||||
==================
|
||||
|
||||
* add support for optional option descriptions
|
||||
* add defaulting of `.version()` to package.json's version
|
||||
|
||||
0.6.1 / 2012-06-01
|
||||
==================
|
||||
|
||||
* Added: append (yes or no) on confirmation
|
||||
* Added: allow node.js v0.7.x
|
||||
|
||||
0.6.0 / 2012-04-10
|
||||
==================
|
||||
|
||||
* Added `.prompt(obj, callback)` support. Closes #49
|
||||
* Added default support to .choose(). Closes #41
|
||||
* Fixed the choice example
|
||||
|
||||
0.5.1 / 2011-12-20
|
||||
==================
|
||||
|
||||
* Fixed `password()` for recent nodes. Closes #36
|
||||
|
||||
0.5.0 / 2011-12-04
|
||||
==================
|
||||
|
||||
* Added sub-command option support [itay]
|
||||
|
||||
0.4.3 / 2011-12-04
|
||||
==================
|
||||
|
||||
* Fixed custom help ordering. Closes #32
|
||||
|
||||
0.4.2 / 2011-11-24
|
||||
==================
|
||||
|
||||
* Added travis support
|
||||
* Fixed: line-buffered input automatically trimmed. Closes #31
|
||||
|
||||
0.4.1 / 2011-11-18
|
||||
==================
|
||||
|
||||
* Removed listening for "close" on --help
|
||||
|
||||
0.4.0 / 2011-11-15
|
||||
==================
|
||||
|
||||
* Added support for `--`. Closes #24
|
||||
|
||||
0.3.3 / 2011-11-14
|
||||
==================
|
||||
|
||||
* Fixed: wait for close event when writing help info [Jerry Hamlet]
|
||||
|
||||
0.3.2 / 2011-11-01
|
||||
==================
|
||||
|
||||
* Fixed long flag definitions with values [felixge]
|
||||
|
||||
0.3.1 / 2011-10-31
|
||||
==================
|
||||
|
||||
* Changed `--version` short flag to `-V` from `-v`
|
||||
* Changed `.version()` so it's configurable [felixge]
|
||||
|
||||
0.3.0 / 2011-10-31
|
||||
==================
|
||||
|
||||
* Added support for long flags only. Closes #18
|
||||
|
||||
0.2.1 / 2011-10-24
|
||||
==================
|
||||
|
||||
* "node": ">= 0.4.x < 0.7.0". Closes #20
|
||||
|
||||
0.2.0 / 2011-09-26
|
||||
==================
|
||||
|
||||
* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
|
||||
|
||||
0.1.0 / 2011-08-24
|
||||
==================
|
||||
|
||||
* Added support for custom `--help` output
|
||||
|
||||
0.0.5 / 2011-08-18
|
||||
==================
|
||||
|
||||
* Changed: when the user enters nothing prompt for password again
|
||||
* Fixed issue with passwords beginning with numbers [NuckChorris]
|
||||
|
||||
0.0.4 / 2011-08-15
|
||||
==================
|
||||
|
||||
* Fixed `Commander#args`
|
||||
|
||||
0.0.3 / 2011-08-15
|
||||
==================
|
||||
|
||||
* Added default option value support
|
||||
|
||||
0.0.2 / 2011-08-15
|
||||
==================
|
||||
|
||||
* Added mask support to `Command#password(str[, mask], fn)`
|
||||
* Added `Command#password(str, fn)`
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
22
bin/tags/node_modules/commander/LICENSE
generated
vendored
22
bin/tags/node_modules/commander/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
428
bin/tags/node_modules/commander/Readme.md
generated
vendored
428
bin/tags/node_modules/commander/Readme.md
generated
vendored
@@ -1,428 +0,0 @@
|
||||
# Commander.js
|
||||
|
||||
|
||||
[](http://travis-ci.org/tj/commander.js)
|
||||
[](https://www.npmjs.org/package/commander)
|
||||
[](https://npmcharts.com/compare/commander?minimal=true)
|
||||
[](https://packagephobia.now.sh/result?p=commander)
|
||||
[](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
|
||||
[API documentation](http://tj.github.com/commander.js/)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install commander
|
||||
|
||||
## Option parsing
|
||||
|
||||
Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-p, --peppers', 'Add peppers')
|
||||
.option('-P, --pineapple', 'Add pineapple')
|
||||
.option('-b, --bbq-sauce', 'Add bbq sauce')
|
||||
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('you ordered a pizza with:');
|
||||
if (program.peppers) console.log(' - peppers');
|
||||
if (program.pineapple) console.log(' - pineapple');
|
||||
if (program.bbqSauce) console.log(' - bbq');
|
||||
console.log(' - %s cheese', program.cheese);
|
||||
```
|
||||
|
||||
Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
|
||||
|
||||
Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.option('--no-sauce', 'Remove sauce')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('you ordered a pizza');
|
||||
if (program.sauce) console.log(' with sauce');
|
||||
else console.log(' without sauce');
|
||||
```
|
||||
|
||||
To get string arguments from options you will need to use angle brackets <> for required inputs or square brackets [] for optional inputs.
|
||||
|
||||
e.g. ```.option('-m --myarg [myVar]', 'my super cool description')```
|
||||
|
||||
Then to access the input if it was passed in.
|
||||
|
||||
e.g. ```var myInput = program.myarg```
|
||||
|
||||
**NOTE**: If you pass a argument without using brackets the example above will return true and not the value passed in.
|
||||
|
||||
|
||||
## Version option
|
||||
|
||||
Calling the `version` implicitly adds the `-V` and `--version` options to the command.
|
||||
When either of these options is present, the command prints the version number and exits.
|
||||
|
||||
$ ./examples/pizza -V
|
||||
0.0.1
|
||||
|
||||
If you want your program to respond to the `-v` option instead of the `-V` option, simply pass custom flags to the `version` method using the same syntax as the `option` method.
|
||||
|
||||
```js
|
||||
program
|
||||
.version('0.0.1', '-v, --version')
|
||||
```
|
||||
|
||||
The version flags can be named anything, but the long option is required.
|
||||
|
||||
## Command-specific options
|
||||
|
||||
You can attach options to a command.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.command('rm <dir>')
|
||||
.option('-r, --recursive', 'Remove recursively')
|
||||
.action(function (dir, cmd) {
|
||||
console.log('remove ' + dir + (cmd.recursive ? ' recursively' : ''))
|
||||
})
|
||||
|
||||
program.parse(process.argv)
|
||||
```
|
||||
|
||||
A command's options are validated when the command is used. Any unknown options will be reported as an error. However, if an action-based command does not define an action, then the options are not validated.
|
||||
|
||||
## Coercion
|
||||
|
||||
```js
|
||||
function range(val) {
|
||||
return val.split('..').map(Number);
|
||||
}
|
||||
|
||||
function list(val) {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
function collect(val, memo) {
|
||||
memo.push(val);
|
||||
return memo;
|
||||
}
|
||||
|
||||
function increaseVerbosity(v, total) {
|
||||
return total + 1;
|
||||
}
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.usage('[options] <file ...>')
|
||||
.option('-i, --integer <n>', 'An integer argument', parseInt)
|
||||
.option('-f, --float <n>', 'A float argument', parseFloat)
|
||||
.option('-r, --range <a>..<b>', 'A range', range)
|
||||
.option('-l, --list <items>', 'A list', list)
|
||||
.option('-o, --optional [value]', 'An optional value')
|
||||
.option('-c, --collect [value]', 'A repeatable value', collect, [])
|
||||
.option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
|
||||
.parse(process.argv);
|
||||
|
||||
console.log(' int: %j', program.integer);
|
||||
console.log(' float: %j', program.float);
|
||||
console.log(' optional: %j', program.optional);
|
||||
program.range = program.range || [];
|
||||
console.log(' range: %j..%j', program.range[0], program.range[1]);
|
||||
console.log(' list: %j', program.list);
|
||||
console.log(' collect: %j', program.collect);
|
||||
console.log(' verbosity: %j', program.verbose);
|
||||
console.log(' args: %j', program.args);
|
||||
```
|
||||
|
||||
## Regular Expression
|
||||
```js
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
|
||||
.option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
|
||||
.parse(process.argv);
|
||||
|
||||
console.log(' size: %j', program.size);
|
||||
console.log(' drink: %j', program.drink);
|
||||
```
|
||||
|
||||
## Variadic arguments
|
||||
|
||||
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
|
||||
append `...` to the argument name. Here is an example:
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('rmdir <dir> [otherDirs...]')
|
||||
.action(function (dir, otherDirs) {
|
||||
console.log('rmdir %s', dir);
|
||||
if (otherDirs) {
|
||||
otherDirs.forEach(function (oDir) {
|
||||
console.log('rmdir %s', oDir);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
|
||||
to your action as demonstrated above.
|
||||
|
||||
## Specify the argument syntax
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.arguments('<cmd> [env]')
|
||||
.action(function (cmd, env) {
|
||||
cmdValue = cmd;
|
||||
envValue = env;
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
if (typeof cmdValue === 'undefined') {
|
||||
console.error('no command given!');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('command:', cmdValue);
|
||||
console.log('environment:', envValue || "no environment given");
|
||||
```
|
||||
Angled brackets (e.g. `<cmd>`) indicate required input. Square brackets (e.g. `[env]`) indicate optional input.
|
||||
|
||||
## Git-style sub-commands
|
||||
|
||||
```js
|
||||
// file: ./examples/pm
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('install [name]', 'install one or more packages')
|
||||
.command('search [query]', 'search with optional query')
|
||||
.command('list', 'list packages installed', {isDefault: true})
|
||||
.parse(process.argv);
|
||||
```
|
||||
|
||||
When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
|
||||
The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
|
||||
|
||||
Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the subcommand from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.
|
||||
|
||||
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
|
||||
|
||||
### `--harmony`
|
||||
|
||||
You can enable `--harmony` option in two ways:
|
||||
* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern.
|
||||
* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.
|
||||
|
||||
## Automated --help
|
||||
|
||||
The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
|
||||
|
||||
```
|
||||
$ ./examples/pizza --help
|
||||
Usage: pizza [options]
|
||||
|
||||
An application for pizzas ordering
|
||||
|
||||
Options:
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
-p, --peppers Add peppers
|
||||
-P, --pineapple Add pineapple
|
||||
-b, --bbq Add bbq sauce
|
||||
-c, --cheese <type> Add the specified type of cheese [marble]
|
||||
-C, --no-cheese You do not want any cheese
|
||||
```
|
||||
|
||||
## Custom help
|
||||
|
||||
You can display arbitrary `-h, --help` information
|
||||
by listening for "--help". Commander will automatically
|
||||
exit once you are done so that the remainder of your program
|
||||
does not execute causing undesired behaviors, for example
|
||||
in the following executable "stuff" will not output when
|
||||
`--help` is used.
|
||||
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-f, --foo', 'enable some foo')
|
||||
.option('-b, --bar', 'enable some bar')
|
||||
.option('-B, --baz', 'enable some baz');
|
||||
|
||||
// must be before .parse() since
|
||||
// node's emit() is immediate
|
||||
|
||||
program.on('--help', function(){
|
||||
console.log('')
|
||||
console.log('Examples:');
|
||||
console.log(' $ custom-help --help');
|
||||
console.log(' $ custom-help -h');
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
console.log('stuff');
|
||||
```
|
||||
|
||||
Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
|
||||
|
||||
```
|
||||
Usage: custom-help [options]
|
||||
|
||||
Options:
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
-f, --foo enable some foo
|
||||
-b, --bar enable some bar
|
||||
-B, --baz enable some baz
|
||||
|
||||
Examples:
|
||||
$ custom-help --help
|
||||
$ custom-help -h
|
||||
```
|
||||
|
||||
## .outputHelp(cb)
|
||||
|
||||
Output help information without exiting.
|
||||
Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
If you want to display help by default (e.g. if no command was provided), you can use something like:
|
||||
|
||||
```js
|
||||
var program = require('commander');
|
||||
var colors = require('colors');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('getstream [url]', 'get stream URL')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
program.outputHelp(make_red);
|
||||
}
|
||||
|
||||
function make_red(txt) {
|
||||
return colors.red(txt); //display the help text in red on the console
|
||||
}
|
||||
```
|
||||
|
||||
## .help(cb)
|
||||
|
||||
Output help information and exit immediately.
|
||||
Optional callback cb allows post-processing of help text before it is displayed.
|
||||
|
||||
|
||||
## Custom event listeners
|
||||
You can execute custom actions by listening to command and option events.
|
||||
|
||||
```js
|
||||
program.on('option:verbose', function () {
|
||||
process.env.VERBOSE = this.verbose;
|
||||
});
|
||||
|
||||
// error on unknown commands
|
||||
program.on('command:*', function () {
|
||||
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
|
||||
process.exit(1);
|
||||
});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
var program = require('commander');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('-C, --chdir <path>', 'change the working directory')
|
||||
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
.option('-T, --no-tests', 'ignore test hook');
|
||||
|
||||
program
|
||||
.command('setup [env]')
|
||||
.description('run setup commands for all envs')
|
||||
.option("-s, --setup_mode [mode]", "Which setup mode to use")
|
||||
.action(function(env, options){
|
||||
var mode = options.setup_mode || "normal";
|
||||
env = env || 'all';
|
||||
console.log('setup for %s env(s) with %s mode', env, mode);
|
||||
});
|
||||
|
||||
program
|
||||
.command('exec <cmd>')
|
||||
.alias('ex')
|
||||
.description('execute the given remote cmd')
|
||||
.option("-e, --exec_mode <mode>", "Which exec mode to use")
|
||||
.action(function(cmd, options){
|
||||
console.log('exec "%s" using %s mode', cmd, options.exec_mode);
|
||||
}).on('--help', function() {
|
||||
console.log('');
|
||||
console.log('Examples:');
|
||||
console.log('');
|
||||
console.log(' $ deploy exec sequential');
|
||||
console.log(' $ deploy exec async');
|
||||
});
|
||||
|
||||
program
|
||||
.command('*')
|
||||
.action(function(env){
|
||||
console.log('deploying "%s"', env);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
```
|
||||
|
||||
More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/tj/commander.js/blob/master/LICENSE)
|
1224
bin/tags/node_modules/commander/index.js
generated
vendored
1224
bin/tags/node_modules/commander/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
70
bin/tags/node_modules/commander/package.json
generated
vendored
70
bin/tags/node_modules/commander/package.json
generated
vendored
@@ -1,70 +0,0 @@
|
||||
{
|
||||
"_from": "commander@^2.14.1",
|
||||
"_id": "commander@2.20.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"_location": "/commander",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "commander@^2.14.1",
|
||||
"name": "commander",
|
||||
"escapedName": "commander",
|
||||
"rawSpec": "^2.14.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.14.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/yaml-front-matter"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"_shasum": "fd485e84c03eb4881c20722ba48035e8531aeb33",
|
||||
"_spec": "commander@^2.14.1",
|
||||
"_where": "/home/ryan/Documents/node_modules/yaml-front-matter",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tj/commander.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "the complete solution for node.js command-line programs",
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.7.8",
|
||||
"eslint": "^6.4.0",
|
||||
"should": "^13.2.3",
|
||||
"sinon": "^7.5.0",
|
||||
"standard": "^14.3.1",
|
||||
"ts-node": "^8.4.1",
|
||||
"typescript": "^3.6.3"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"typings/index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/tj/commander.js#readme",
|
||||
"keywords": [
|
||||
"commander",
|
||||
"command",
|
||||
"option",
|
||||
"parser"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index",
|
||||
"name": "commander",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tj/commander.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint index.js",
|
||||
"test": "node test/run.js && npm run test-typings",
|
||||
"test-typings": "tsc -p tsconfig.json"
|
||||
},
|
||||
"typings": "typings/index.d.ts",
|
||||
"version": "2.20.3"
|
||||
}
|
310
bin/tags/node_modules/commander/typings/index.d.ts
generated
vendored
310
bin/tags/node_modules/commander/typings/index.d.ts
generated
vendored
@@ -1,310 +0,0 @@
|
||||
// Type definitions for commander 2.11
|
||||
// Project: https://github.com/visionmedia/commander.js
|
||||
// Definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace local {
|
||||
|
||||
class Option {
|
||||
flags: string;
|
||||
required: boolean;
|
||||
optional: boolean;
|
||||
bool: boolean;
|
||||
short?: string;
|
||||
long: string;
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Initialize a new `Option` with the given `flags` and `description`.
|
||||
*
|
||||
* @param {string} flags
|
||||
* @param {string} [description]
|
||||
*/
|
||||
constructor(flags: string, description?: string);
|
||||
}
|
||||
|
||||
class Command extends NodeJS.EventEmitter {
|
||||
[key: string]: any;
|
||||
|
||||
args: string[];
|
||||
|
||||
/**
|
||||
* Initialize a new `Command`.
|
||||
*
|
||||
* @param {string} [name]
|
||||
*/
|
||||
constructor(name?: string);
|
||||
|
||||
/**
|
||||
* Set the program version to `str`.
|
||||
*
|
||||
* This method auto-registers the "-V, --version" flag
|
||||
* which will print the version number when passed.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} [flags]
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
version(str: string, flags?: string): Command;
|
||||
|
||||
/**
|
||||
* Add command `name`.
|
||||
*
|
||||
* The `.action()` callback is invoked when the
|
||||
* command `name` is specified via __ARGV__,
|
||||
* and the remaining arguments are applied to the
|
||||
* function for access.
|
||||
*
|
||||
* When the `name` is "*" an un-matched command
|
||||
* will be passed as the first arg, followed by
|
||||
* the rest of __ARGV__ remaining.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .version('0.0.1')
|
||||
* .option('-C, --chdir <path>', 'change the working directory')
|
||||
* .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
* .option('-T, --no-tests', 'ignore test hook')
|
||||
*
|
||||
* program
|
||||
* .command('setup')
|
||||
* .description('run remote setup commands')
|
||||
* .action(function() {
|
||||
* console.log('setup');
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('exec <cmd>')
|
||||
* .description('run the given remote command')
|
||||
* .action(function(cmd) {
|
||||
* console.log('exec "%s"', cmd);
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('teardown <dir> [otherDirs...]')
|
||||
* .description('run teardown commands')
|
||||
* .action(function(dir, otherDirs) {
|
||||
* console.log('dir "%s"', dir);
|
||||
* if (otherDirs) {
|
||||
* otherDirs.forEach(function (oDir) {
|
||||
* console.log('dir "%s"', oDir);
|
||||
* });
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('*')
|
||||
* .description('deploy the given env')
|
||||
* .action(function(env) {
|
||||
* console.log('deploying "%s"', env);
|
||||
* });
|
||||
*
|
||||
* program.parse(process.argv);
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} [desc] for git-style sub-commands
|
||||
* @param {CommandOptions} [opts] command options
|
||||
* @returns {Command} the new command
|
||||
*/
|
||||
command(name: string, desc?: string, opts?: commander.CommandOptions): Command;
|
||||
|
||||
/**
|
||||
* Define argument syntax for the top-level command.
|
||||
*
|
||||
* @param {string} desc
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
arguments(desc: string): Command;
|
||||
|
||||
/**
|
||||
* Parse expected `args`.
|
||||
*
|
||||
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
|
||||
*
|
||||
* @param {string[]} args
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
parseExpectedArgs(args: string[]): Command;
|
||||
|
||||
/**
|
||||
* Register callback `fn` for the command.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .command('help')
|
||||
* .description('display verbose help')
|
||||
* .action(function() {
|
||||
* // output help here
|
||||
* });
|
||||
*
|
||||
* @param {(...args: any[]) => void} fn
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
action(fn: (...args: any[]) => void): Command;
|
||||
|
||||
/**
|
||||
* Define option with `flags`, `description` and optional
|
||||
* coercion `fn`.
|
||||
*
|
||||
* The `flags` string should contain both the short and long flags,
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when `--help` is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* @example
|
||||
* // simple boolean defaulting to false
|
||||
* program.option('-p, --pepper', 'add pepper');
|
||||
*
|
||||
* --pepper
|
||||
* program.pepper
|
||||
* // => Boolean
|
||||
*
|
||||
* // simple boolean defaulting to true
|
||||
* program.option('-C, --no-cheese', 'remove cheese');
|
||||
*
|
||||
* program.cheese
|
||||
* // => true
|
||||
*
|
||||
* --no-cheese
|
||||
* program.cheese
|
||||
* // => false
|
||||
*
|
||||
* // required argument
|
||||
* program.option('-C, --chdir <path>', 'change the working directory');
|
||||
*
|
||||
* --chdir /tmp
|
||||
* program.chdir
|
||||
* // => "/tmp"
|
||||
*
|
||||
* // optional argument
|
||||
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
||||
*
|
||||
* @param {string} flags
|
||||
* @param {string} [description]
|
||||
* @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default
|
||||
* @param {*} [defaultValue]
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
|
||||
option(flags: string, description?: string, defaultValue?: any): Command;
|
||||
|
||||
/**
|
||||
* Allow unknown options on the command line.
|
||||
*
|
||||
* @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options.
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
allowUnknownOption(arg?: boolean): Command;
|
||||
|
||||
/**
|
||||
* Parse `argv`, settings options and invoking commands when defined.
|
||||
*
|
||||
* @param {string[]} argv
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
parse(argv: string[]): Command;
|
||||
|
||||
/**
|
||||
* Parse options from `argv` returning `argv` void of these options.
|
||||
*
|
||||
* @param {string[]} argv
|
||||
* @returns {ParseOptionsResult}
|
||||
*/
|
||||
parseOptions(argv: string[]): commander.ParseOptionsResult;
|
||||
|
||||
/**
|
||||
* Return an object containing options as key-value pairs
|
||||
*
|
||||
* @returns {{[key: string]: any}}
|
||||
*/
|
||||
opts(): { [key: string]: any };
|
||||
|
||||
/**
|
||||
* Set the description to `str`.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {{[argName: string]: string}} argsDescription
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
description(str: string, argsDescription?: {[argName: string]: string}): Command;
|
||||
description(): string;
|
||||
|
||||
/**
|
||||
* Set an alias for the command.
|
||||
*
|
||||
* @param {string} alias
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
alias(alias: string): Command;
|
||||
alias(): string;
|
||||
|
||||
/**
|
||||
* Set or get the command usage.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
usage(str: string): Command;
|
||||
usage(): string;
|
||||
|
||||
/**
|
||||
* Set the name of the command.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {Command}
|
||||
*/
|
||||
name(str: string): Command;
|
||||
|
||||
/**
|
||||
* Get the name of the command.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Output help information for this command.
|
||||
*
|
||||
* @param {(str: string) => string} [cb]
|
||||
*/
|
||||
outputHelp(cb?: (str: string) => string): void;
|
||||
|
||||
/** Output help information and exit.
|
||||
*
|
||||
* @param {(str: string) => string} [cb]
|
||||
*/
|
||||
help(cb?: (str: string) => string): never;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare namespace commander {
|
||||
|
||||
type Command = local.Command
|
||||
|
||||
type Option = local.Option
|
||||
|
||||
interface CommandOptions {
|
||||
noHelp?: boolean;
|
||||
isDefault?: boolean;
|
||||
}
|
||||
|
||||
interface ParseOptionsResult {
|
||||
args: string[];
|
||||
unknown: string[];
|
||||
}
|
||||
|
||||
interface CommanderStatic extends Command {
|
||||
Command: typeof local.Command;
|
||||
Option: typeof local.Option;
|
||||
CommandOptions: CommandOptions;
|
||||
ParseOptionsResult: ParseOptionsResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare const commander: commander.CommanderStatic;
|
||||
export = commander;
|
4
bin/tags/node_modules/concat-map/.travis.yml
generated
vendored
4
bin/tags/node_modules/concat-map/.travis.yml
generated
vendored
@@ -1,4 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
18
bin/tags/node_modules/concat-map/LICENSE
generated
vendored
18
bin/tags/node_modules/concat-map/LICENSE
generated
vendored
@@ -1,18 +0,0 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
62
bin/tags/node_modules/concat-map/README.markdown
generated
vendored
62
bin/tags/node_modules/concat-map/README.markdown
generated
vendored
@@ -1,62 +0,0 @@
|
||||
concat-map
|
||||
==========
|
||||
|
||||
Concatenative mapdashery.
|
||||
|
||||
[](http://ci.testling.com/substack/node-concat-map)
|
||||
|
||||
[](http://travis-ci.org/substack/node-concat-map)
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
``` js
|
||||
var concatMap = require('concat-map');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
```
|
||||
[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]
|
||||
```
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
``` js
|
||||
var concatMap = require('concat-map')
|
||||
```
|
||||
|
||||
concatMap(xs, fn)
|
||||
-----------------
|
||||
|
||||
Return an array of concatenated elements by calling `fn(x, i)` for each element
|
||||
`x` and each index `i` in the array `xs`.
|
||||
|
||||
When `fn(x, i)` returns an array, its result will be concatenated with the
|
||||
result array. If `fn(x, i)` returns anything else, that value will be pushed
|
||||
onto the end of the result array.
|
||||
|
||||
install
|
||||
=======
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install concat-map
|
||||
```
|
||||
|
||||
license
|
||||
=======
|
||||
|
||||
MIT
|
||||
|
||||
notes
|
||||
=====
|
||||
|
||||
This module was written while sitting high above the ground in a tree.
|
6
bin/tags/node_modules/concat-map/example/map.js
generated
vendored
6
bin/tags/node_modules/concat-map/example/map.js
generated
vendored
@@ -1,6 +0,0 @@
|
||||
var concatMap = require('../');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
13
bin/tags/node_modules/concat-map/index.js
generated
vendored
13
bin/tags/node_modules/concat-map/index.js
generated
vendored
@@ -1,13 +0,0 @@
|
||||
module.exports = function (xs, fn) {
|
||||
var res = [];
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
var x = fn(xs[i], i);
|
||||
if (isArray(x)) res.push.apply(res, x);
|
||||
else res.push(x);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
var isArray = Array.isArray || function (xs) {
|
||||
return Object.prototype.toString.call(xs) === '[object Array]';
|
||||
};
|
88
bin/tags/node_modules/concat-map/package.json
generated
vendored
88
bin/tags/node_modules/concat-map/package.json
generated
vendored
@@ -1,88 +0,0 @@
|
||||
{
|
||||
"_from": "concat-map@0.0.1",
|
||||
"_id": "concat-map@0.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"_location": "/concat-map",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "concat-map@0.0.1",
|
||||
"name": "concat-map",
|
||||
"escapedName": "concat-map",
|
||||
"rawSpec": "0.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/brace-expansion"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
||||
"_spec": "concat-map@0.0.1",
|
||||
"_where": "/home/ryan/Documents/node_modules/brace-expansion",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-concat-map/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "concatenative mapdashery",
|
||||
"devDependencies": {
|
||||
"tape": "~2.4.0"
|
||||
},
|
||||
"directories": {
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-concat-map#readme",
|
||||
"keywords": [
|
||||
"concat",
|
||||
"concatMap",
|
||||
"map",
|
||||
"functional",
|
||||
"higher-order"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "concat-map",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-concat-map.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": {
|
||||
"ie": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9
|
||||
],
|
||||
"ff": [
|
||||
3.5,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"chrome": [
|
||||
10,
|
||||
22
|
||||
],
|
||||
"safari": [
|
||||
5.1
|
||||
],
|
||||
"opera": [
|
||||
12
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": "0.0.1"
|
||||
}
|
39
bin/tags/node_modules/concat-map/test/map.js
generated
vendored
39
bin/tags/node_modules/concat-map/test/map.js
generated
vendored
@@ -1,39 +0,0 @@
|
||||
var concatMap = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('empty or not', function (t) {
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ixes = [];
|
||||
var ys = concatMap(xs, function (x, ix) {
|
||||
ixes.push(ix);
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]);
|
||||
t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('always something', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ];
|
||||
});
|
||||
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('scalars', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x === 'b' ? [ 'B', 'B', 'B' ] : x;
|
||||
});
|
||||
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('undefs', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function () {});
|
||||
t.same(ys, [ undefined, undefined, undefined, undefined ]);
|
||||
t.end();
|
||||
});
|
235
bin/tags/node_modules/esprima/ChangeLog
generated
vendored
235
bin/tags/node_modules/esprima/ChangeLog
generated
vendored
@@ -1,235 +0,0 @@
|
||||
2018-06-17: Version 4.0.1
|
||||
|
||||
* Fix parsing async get/set in a class (issue 1861, 1875)
|
||||
* Account for different return statement argument (issue 1829, 1897, 1928)
|
||||
* Correct the handling of HTML comment when parsing a module (issue 1841)
|
||||
* Fix incorrect parse async with proto-identifier-shorthand (issue 1847)
|
||||
* Fix negative column in binary expression (issue 1844)
|
||||
* Fix incorrect YieldExpression in object methods (issue 1834)
|
||||
* Various documentation fixes
|
||||
|
||||
2017-06-10: Version 4.0.0
|
||||
|
||||
* Support ES2017 async function and await expression (issue 1079)
|
||||
* Support ES2017 trailing commas in function parameters (issue 1550)
|
||||
* Explicitly distinguish parsing a module vs a script (issue 1576)
|
||||
* Fix JSX non-empty container (issue 1786)
|
||||
* Allow JSX element in a yield expression (issue 1765)
|
||||
* Allow `in` expression in a concise body with a function body (issue 1793)
|
||||
* Setter function argument must not be a rest parameter (issue 1693)
|
||||
* Limit strict mode directive to functions with a simple parameter list (issue 1677)
|
||||
* Prohibit any escape sequence in a reserved word (issue 1612)
|
||||
* Only permit hex digits in hex escape sequence (issue 1619)
|
||||
* Prohibit labelled class/generator/function declaration (issue 1484)
|
||||
* Limit function declaration as if statement clause only in non-strict mode (issue 1657)
|
||||
* Tolerate missing ) in a with and do-while statement (issue 1481)
|
||||
|
||||
2016-12-22: Version 3.1.3
|
||||
|
||||
* Support binding patterns as rest element (issue 1681)
|
||||
* Account for different possible arguments of a yield expression (issue 1469)
|
||||
|
||||
2016-11-24: Version 3.1.2
|
||||
|
||||
* Ensure that import specifier is more restrictive (issue 1615)
|
||||
* Fix duplicated JSX tokens (issue 1613)
|
||||
* Scan template literal in a JSX expression container (issue 1622)
|
||||
* Improve XHTML entity scanning in JSX (issue 1629)
|
||||
|
||||
2016-10-31: Version 3.1.1
|
||||
|
||||
* Fix assignment expression problem in an export declaration (issue 1596)
|
||||
* Fix incorrect tokenization of hex digits (issue 1605)
|
||||
|
||||
2016-10-09: Version 3.1.0
|
||||
|
||||
* Do not implicitly collect comments when comment attachment is specified (issue 1553)
|
||||
* Fix incorrect handling of duplicated proto shorthand fields (issue 1485)
|
||||
* Prohibit initialization in some variants of for statements (issue 1309, 1561)
|
||||
* Fix incorrect parsing of export specifier (issue 1578)
|
||||
* Fix ESTree compatibility for assignment pattern (issue 1575)
|
||||
|
||||
2016-09-03: Version 3.0.0
|
||||
|
||||
* Support ES2016 exponentiation expression (issue 1490)
|
||||
* Support JSX syntax (issue 1467)
|
||||
* Use the latest Unicode 8.0 (issue 1475)
|
||||
* Add the support for syntax node delegate (issue 1435)
|
||||
* Fix ESTree compatibility on meta property (issue 1338)
|
||||
* Fix ESTree compatibility on default parameter value (issue 1081)
|
||||
* Fix ESTree compatibility on try handler (issue 1030)
|
||||
|
||||
2016-08-23: Version 2.7.3
|
||||
|
||||
* Fix tokenizer confusion with a comment (issue 1493, 1516)
|
||||
|
||||
2016-02-02: Version 2.7.2
|
||||
|
||||
* Fix out-of-bound error location in an invalid string literal (issue 1457)
|
||||
* Fix shorthand object destructuring defaults in variable declarations (issue 1459)
|
||||
|
||||
2015-12-10: Version 2.7.1
|
||||
|
||||
* Do not allow trailing comma in a variable declaration (issue 1360)
|
||||
* Fix assignment to `let` in non-strict mode (issue 1376)
|
||||
* Fix missing delegate property in YieldExpression (issue 1407)
|
||||
|
||||
2015-10-22: Version 2.7.0
|
||||
|
||||
* Fix the handling of semicolon in a break statement (issue 1044)
|
||||
* Run the test suite with major web browsers (issue 1259, 1317)
|
||||
* Allow `let` as an identifier in non-strict mode (issue 1289)
|
||||
* Attach orphaned comments as `innerComments` (issue 1328)
|
||||
* Add the support for token delegator (issue 1332)
|
||||
|
||||
2015-09-01: Version 2.6.0
|
||||
|
||||
* Properly allow or prohibit `let` in a binding identifier/pattern (issue 1048, 1098)
|
||||
* Add sourceType field for Program node (issue 1159)
|
||||
* Ensure that strict mode reserved word binding throw an error (issue 1171)
|
||||
* Run the test suite with Node.js and IE 11 on Windows (issue 1294)
|
||||
* Allow binding pattern with no initializer in a for statement (issue 1301)
|
||||
|
||||
2015-07-31: Version 2.5.0
|
||||
|
||||
* Run the test suite in a browser environment (issue 1004)
|
||||
* Ensure a comma between imported default binding and named imports (issue 1046)
|
||||
* Distinguish `yield` as a keyword vs an identifier (issue 1186)
|
||||
* Support ES6 meta property `new.target` (issue 1203)
|
||||
* Fix the syntax node for yield with expression (issue 1223)
|
||||
* Fix the check of duplicated proto in property names (issue 1225)
|
||||
* Fix ES6 Unicode escape in identifier name (issue 1229)
|
||||
* Support ES6 IdentifierStart and IdentifierPart (issue 1232)
|
||||
* Treat await as a reserved word when parsing as a module (issue 1234)
|
||||
* Recognize identifier characters from Unicode SMP (issue 1244)
|
||||
* Ensure that export and import can be followed by a comma (issue 1250)
|
||||
* Fix yield operator precedence (issue 1262)
|
||||
|
||||
2015-07-01: Version 2.4.1
|
||||
|
||||
* Fix some cases of comment attachment (issue 1071, 1175)
|
||||
* Fix the handling of destructuring in function arguments (issue 1193)
|
||||
* Fix invalid ranges in assignment expression (issue 1201)
|
||||
|
||||
2015-06-26: Version 2.4.0
|
||||
|
||||
* Support ES6 for-of iteration (issue 1047)
|
||||
* Support ES6 spread arguments (issue 1169)
|
||||
* Minimize npm payload (issue 1191)
|
||||
|
||||
2015-06-16: Version 2.3.0
|
||||
|
||||
* Support ES6 generator (issue 1033)
|
||||
* Improve parsing of regular expressions with `u` flag (issue 1179)
|
||||
|
||||
2015-04-17: Version 2.2.0
|
||||
|
||||
* Support ES6 import and export declarations (issue 1000)
|
||||
* Fix line terminator before arrow not recognized as error (issue 1009)
|
||||
* Support ES6 destructuring (issue 1045)
|
||||
* Support ES6 template literal (issue 1074)
|
||||
* Fix the handling of invalid/incomplete string escape sequences (issue 1106)
|
||||
* Fix ES3 static member access restriction (issue 1120)
|
||||
* Support for `super` in ES6 class (issue 1147)
|
||||
|
||||
2015-03-09: Version 2.1.0
|
||||
|
||||
* Support ES6 class (issue 1001)
|
||||
* Support ES6 rest parameter (issue 1011)
|
||||
* Expand the location of property getter, setter, and methods (issue 1029)
|
||||
* Enable TryStatement transition to a single handler (issue 1031)
|
||||
* Support ES6 computed property name (issue 1037)
|
||||
* Tolerate unclosed block comment (issue 1041)
|
||||
* Support ES6 lexical declaration (issue 1065)
|
||||
|
||||
2015-02-06: Version 2.0.0
|
||||
|
||||
* Support ES6 arrow function (issue 517)
|
||||
* Support ES6 Unicode code point escape (issue 521)
|
||||
* Improve the speed and accuracy of comment attachment (issue 522)
|
||||
* Support ES6 default parameter (issue 519)
|
||||
* Support ES6 regular expression flags (issue 557)
|
||||
* Fix scanning of implicit octal literals (issue 565)
|
||||
* Fix the handling of automatic semicolon insertion (issue 574)
|
||||
* Support ES6 method definition (issue 620)
|
||||
* Support ES6 octal integer literal (issue 621)
|
||||
* Support ES6 binary integer literal (issue 622)
|
||||
* Support ES6 object literal property value shorthand (issue 624)
|
||||
|
||||
2015-03-03: Version 1.2.5
|
||||
|
||||
* Fix scanning of implicit octal literals (issue 565)
|
||||
|
||||
2015-02-05: Version 1.2.4
|
||||
|
||||
* Fix parsing of LeftHandSideExpression in ForInStatement (issue 560)
|
||||
* Fix the handling of automatic semicolon insertion (issue 574)
|
||||
|
||||
2015-01-18: Version 1.2.3
|
||||
|
||||
* Fix division by this (issue 616)
|
||||
|
||||
2014-05-18: Version 1.2.2
|
||||
|
||||
* Fix duplicated tokens when collecting comments (issue 537)
|
||||
|
||||
2014-05-04: Version 1.2.1
|
||||
|
||||
* Ensure that Program node may still have leading comments (issue 536)
|
||||
|
||||
2014-04-29: Version 1.2.0
|
||||
|
||||
* Fix semicolon handling for expression statement (issue 462, 533)
|
||||
* Disallow escaped characters in regular expression flags (issue 503)
|
||||
* Performance improvement for location tracking (issue 520)
|
||||
* Improve the speed of comment attachment (issue 522)
|
||||
|
||||
2014-03-26: Version 1.1.1
|
||||
|
||||
* Fix token handling of forward slash after an array literal (issue 512)
|
||||
|
||||
2014-03-23: Version 1.1.0
|
||||
|
||||
* Optionally attach comments to the owning syntax nodes (issue 197)
|
||||
* Simplify binary parsing with stack-based shift reduce (issue 352)
|
||||
* Always include the raw source of literals (issue 376)
|
||||
* Add optional input source information (issue 386)
|
||||
* Tokenizer API for pure lexical scanning (issue 398)
|
||||
* Improve the web site and its online demos (issue 337, 400, 404)
|
||||
* Performance improvement for location tracking (issue 417, 424)
|
||||
* Support HTML comment syntax (issue 451)
|
||||
* Drop support for legacy browsers (issue 474)
|
||||
|
||||
2013-08-27: Version 1.0.4
|
||||
|
||||
* Minimize the payload for packages (issue 362)
|
||||
* Fix missing cases on an empty switch statement (issue 436)
|
||||
* Support escaped ] in regexp literal character classes (issue 442)
|
||||
* Tolerate invalid left-hand side expression (issue 130)
|
||||
|
||||
2013-05-17: Version 1.0.3
|
||||
|
||||
* Variable declaration needs at least one declarator (issue 391)
|
||||
* Fix benchmark's variance unit conversion (issue 397)
|
||||
* IE < 9: \v should be treated as vertical tab (issue 405)
|
||||
* Unary expressions should always have prefix: true (issue 418)
|
||||
* Catch clause should only accept an identifier (issue 423)
|
||||
* Tolerate setters without parameter (issue 426)
|
||||
|
||||
2012-11-02: Version 1.0.2
|
||||
|
||||
Improvement:
|
||||
|
||||
* Fix esvalidate JUnit output upon a syntax error (issue 374)
|
||||
|
||||
2012-10-28: Version 1.0.1
|
||||
|
||||
Improvements:
|
||||
|
||||
* esvalidate understands shebang in a Unix shell script (issue 361)
|
||||
* esvalidate treats fatal parsing failure as an error (issue 361)
|
||||
* Reduce Node.js package via .npmignore (issue 362)
|
||||
|
||||
2012-10-22: Version 1.0.0
|
||||
|
||||
Initial release.
|
21
bin/tags/node_modules/esprima/LICENSE.BSD
generated
vendored
21
bin/tags/node_modules/esprima/LICENSE.BSD
generated
vendored
@@ -1,21 +0,0 @@
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
46
bin/tags/node_modules/esprima/README.md
generated
vendored
46
bin/tags/node_modules/esprima/README.md
generated
vendored
@@ -1,46 +0,0 @@
|
||||
[](https://www.npmjs.com/package/esprima)
|
||||
[](https://www.npmjs.com/package/esprima)
|
||||
[](https://travis-ci.org/jquery/esprima)
|
||||
[](https://codecov.io/github/jquery/esprima)
|
||||
|
||||
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
|
||||
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
parser written in ECMAScript (also popularly known as
|
||||
[JavaScript](https://en.wikipedia.org/wiki/JavaScript)).
|
||||
Esprima is created and maintained by [Ariya Hidayat](https://twitter.com/ariyahidayat),
|
||||
with the help of [many contributors](https://github.com/jquery/esprima/contributors).
|
||||
|
||||
### Features
|
||||
|
||||
- Full support for ECMAScript 2017 ([ECMA-262 8th Edition](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
|
||||
- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree)
|
||||
- Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/)
|
||||
- Optional tracking of syntax node location (index-based and line-column)
|
||||
- [Heavily tested](http://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://codecov.io/github/jquery/esprima))
|
||||
|
||||
### API
|
||||
|
||||
Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) (tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program.
|
||||
|
||||
A simple example on Node.js REPL:
|
||||
|
||||
```javascript
|
||||
> var esprima = require('esprima');
|
||||
> var program = 'const answer = 42';
|
||||
|
||||
> esprima.tokenize(program);
|
||||
[ { type: 'Keyword', value: 'const' },
|
||||
{ type: 'Identifier', value: 'answer' },
|
||||
{ type: 'Punctuator', value: '=' },
|
||||
{ type: 'Numeric', value: '42' } ]
|
||||
|
||||
> esprima.parseScript(program);
|
||||
{ type: 'Program',
|
||||
body:
|
||||
[ { type: 'VariableDeclaration',
|
||||
declarations: [Object],
|
||||
kind: 'const' } ],
|
||||
sourceType: 'script' }
|
||||
```
|
||||
|
||||
For more information, please read the [complete documentation](http://esprima.org/doc).
|
139
bin/tags/node_modules/esprima/bin/esparse.js
generated
vendored
139
bin/tags/node_modules/esprima/bin/esparse.js
generated
vendored
@@ -1,139 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true node:true rhino:true */
|
||||
|
||||
var fs, esprima, fname, forceFile, content, options, syntax;
|
||||
|
||||
if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
try {
|
||||
esprima = require('esprima');
|
||||
} catch (e) {
|
||||
esprima = require('../');
|
||||
}
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = { argv: arguments, exit: quit };
|
||||
process.argv.unshift('esparse.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esparse [options] [file.js]');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --comment Gather all line and block comments in an array');
|
||||
console.log(' --loc Include line-column location info for each syntax node');
|
||||
console.log(' --range Include index-based range for each syntax node');
|
||||
console.log(' --raw Display the raw value of literals');
|
||||
console.log(' --tokens List all tokens in an array');
|
||||
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
||||
console.log(' -v, --version Shows program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
options = {};
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (forceFile || entry === '-' || entry.slice(0, 1) !== '-') {
|
||||
if (typeof fname === 'string') {
|
||||
console.log('Error: more than one input file.');
|
||||
process.exit(1);
|
||||
} else {
|
||||
fname = entry;
|
||||
}
|
||||
} else if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry === '--comment') {
|
||||
options.comment = true;
|
||||
} else if (entry === '--loc') {
|
||||
options.loc = true;
|
||||
} else if (entry === '--range') {
|
||||
options.range = true;
|
||||
} else if (entry === '--raw') {
|
||||
options.raw = true;
|
||||
} else if (entry === '--tokens') {
|
||||
options.tokens = true;
|
||||
} else if (entry === '--tolerant') {
|
||||
options.tolerant = true;
|
||||
} else if (entry === '--') {
|
||||
forceFile = true;
|
||||
} else {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
// Special handling for regular expression literal since we need to
|
||||
// convert it to a string literal, otherwise it will be decoded
|
||||
// as object "{}" and the regular expression would be lost.
|
||||
function adjustRegexLiteral(key, value) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function run(content) {
|
||||
syntax = esprima.parse(content, options);
|
||||
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
|
||||
}
|
||||
|
||||
try {
|
||||
if (fname && (fname !== '-' || forceFile)) {
|
||||
run(fs.readFileSync(fname, 'utf-8'));
|
||||
} else {
|
||||
var content = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(chunk) {
|
||||
content += chunk;
|
||||
});
|
||||
process.stdin.on('end', function() {
|
||||
run(content);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error: ' + e.message);
|
||||
process.exit(1);
|
||||
}
|
236
bin/tags/node_modules/esprima/bin/esvalidate.js
generated
vendored
236
bin/tags/node_modules/esprima/bin/esvalidate.js
generated
vendored
@@ -1,236 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true plusplus:true node:true rhino:true */
|
||||
/*global phantom:true */
|
||||
|
||||
var fs, system, esprima, options, fnames, forceFile, count;
|
||||
|
||||
if (typeof esprima === 'undefined') {
|
||||
// PhantomJS can only require() relative files
|
||||
if (typeof phantom === 'object') {
|
||||
fs = require('fs');
|
||||
system = require('system');
|
||||
esprima = require('./esprima');
|
||||
} else if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
try {
|
||||
esprima = require('esprima');
|
||||
} catch (e) {
|
||||
esprima = require('../');
|
||||
}
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under PhantomJS 1.7+.
|
||||
if (typeof phantom === 'object') {
|
||||
fs.readFileSync = fs.read;
|
||||
process = {
|
||||
argv: [].slice.call(system.args),
|
||||
exit: phantom.exit,
|
||||
on: function (evt, callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
process.argv.unshift('phantomjs');
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = {
|
||||
argv: arguments,
|
||||
exit: quit,
|
||||
on: function (evt, callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
process.argv.unshift('esvalidate.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esvalidate [options] [file.js...]');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --format=type Set the report format, plain (default) or junit');
|
||||
console.log(' -v, --version Print program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
options = {
|
||||
format: 'plain'
|
||||
};
|
||||
|
||||
fnames = [];
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (forceFile || entry === '-' || entry.slice(0, 1) !== '-') {
|
||||
fnames.push(entry);
|
||||
} else if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Validator (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry.slice(0, 9) === '--format=') {
|
||||
options.format = entry.slice(9);
|
||||
if (options.format !== 'plain' && options.format !== 'junit') {
|
||||
console.log('Error: unknown report format ' + options.format + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (entry === '--') {
|
||||
forceFile = true;
|
||||
} else {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (fnames.length === 0) {
|
||||
fnames.push('');
|
||||
}
|
||||
|
||||
if (options.format === 'junit') {
|
||||
console.log('<?xml version="1.0" encoding="UTF-8"?>');
|
||||
console.log('<testsuites>');
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
function run(fname, content) {
|
||||
var timestamp, syntax, name;
|
||||
try {
|
||||
if (typeof content !== 'string') {
|
||||
throw content;
|
||||
}
|
||||
|
||||
if (content[0] === '#' && content[1] === '!') {
|
||||
content = '//' + content.substr(2, content.length);
|
||||
}
|
||||
|
||||
timestamp = Date.now();
|
||||
syntax = esprima.parse(content, { tolerant: true });
|
||||
|
||||
if (options.format === 'junit') {
|
||||
|
||||
name = fname;
|
||||
if (name.lastIndexOf('/') >= 0) {
|
||||
name = name.slice(name.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
console.log('<testsuite name="' + fname + '" errors="0" ' +
|
||||
' failures="' + syntax.errors.length + '" ' +
|
||||
' tests="' + syntax.errors.length + '" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) +
|
||||
'">');
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
console.log(' <testcase name="Line ' + error.lineNumber + ': ' + msg + '" ' +
|
||||
' time="0">');
|
||||
console.log(' <error type="SyntaxError" message="' + error.message + '">' +
|
||||
error.message + '(' + name + ':' + error.lineNumber + ')' +
|
||||
'</error>');
|
||||
console.log(' </testcase>');
|
||||
});
|
||||
|
||||
console.log('</testsuite>');
|
||||
|
||||
} else if (options.format === 'plain') {
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
msg = fname + ':' + error.lineNumber + ': ' + msg;
|
||||
console.log(msg);
|
||||
++count;
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
++count;
|
||||
if (options.format === 'junit') {
|
||||
console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
|
||||
console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
|
||||
console.log(' <error type="ParseError" message="' + e.message + '">' +
|
||||
e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
|
||||
')</error>');
|
||||
console.log(' </testcase>');
|
||||
console.log('</testsuite>');
|
||||
} else {
|
||||
console.log(fname + ':' + e.lineNumber + ': ' + e.message.replace(/^Line\ [0-9]*\:\ /, ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fnames.forEach(function (fname) {
|
||||
var content = '';
|
||||
try {
|
||||
if (fname && (fname !== '-' || forceFile)) {
|
||||
content = fs.readFileSync(fname, 'utf-8');
|
||||
} else {
|
||||
fname = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(chunk) {
|
||||
content += chunk;
|
||||
});
|
||||
process.stdin.on('end', function() {
|
||||
run(fname, content);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
content = e;
|
||||
}
|
||||
run(fname, content);
|
||||
});
|
||||
|
||||
process.on('exit', function () {
|
||||
if (options.format === 'junit') {
|
||||
console.log('</testsuites>');
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (count === 0 && typeof phantom === 'object') {
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
6709
bin/tags/node_modules/esprima/dist/esprima.js
generated
vendored
6709
bin/tags/node_modules/esprima/dist/esprima.js
generated
vendored
File diff suppressed because one or more lines are too long
137
bin/tags/node_modules/esprima/package.json
generated
vendored
137
bin/tags/node_modules/esprima/package.json
generated
vendored
@@ -1,137 +0,0 @@
|
||||
{
|
||||
"_from": "esprima@^4.0.0",
|
||||
"_id": "esprima@4.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"_location": "/esprima",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "esprima@^4.0.0",
|
||||
"name": "esprima",
|
||||
"escapedName": "esprima",
|
||||
"rawSpec": "^4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/js-yaml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"_shasum": "13b04cdb3e6c5d19df91ab6987a8695619b0aa71",
|
||||
"_spec": "esprima@^4.0.0",
|
||||
"_where": "/home/ryan/Documents/node_modules/js-yaml",
|
||||
"author": {
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jquery/esprima/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
|
||||
"devDependencies": {
|
||||
"codecov.io": "~0.1.6",
|
||||
"escomplex-js": "1.2.0",
|
||||
"everything.js": "~1.0.3",
|
||||
"glob": "~7.1.0",
|
||||
"istanbul": "~0.4.0",
|
||||
"json-diff": "~0.3.1",
|
||||
"karma": "~1.3.0",
|
||||
"karma-chrome-launcher": "~2.0.0",
|
||||
"karma-detect-browsers": "~2.2.3",
|
||||
"karma-edge-launcher": "~0.2.0",
|
||||
"karma-firefox-launcher": "~1.0.0",
|
||||
"karma-ie-launcher": "~1.0.0",
|
||||
"karma-mocha": "~1.3.0",
|
||||
"karma-safari-launcher": "~1.0.0",
|
||||
"karma-safaritechpreview-launcher": "~0.0.4",
|
||||
"karma-sauce-launcher": "~1.1.0",
|
||||
"lodash": "~3.10.1",
|
||||
"mocha": "~3.2.0",
|
||||
"node-tick-processor": "~0.0.2",
|
||||
"regenerate": "~1.3.2",
|
||||
"temp": "~0.8.3",
|
||||
"tslint": "~5.1.0",
|
||||
"typescript": "~2.3.2",
|
||||
"typescript-formatter": "~5.1.3",
|
||||
"unicode-8.0.0": "~0.7.0",
|
||||
"webpack": "~1.14.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist/esprima.js"
|
||||
],
|
||||
"homepage": "http://esprima.org",
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"esprima",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "dist/esprima.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com",
|
||||
"url": "http://ariya.ofilabs.com"
|
||||
}
|
||||
],
|
||||
"name": "esprima",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jquery/esprima.git"
|
||||
},
|
||||
"scripts": {
|
||||
"all-tests": "npm run verify-line-ending && npm run generate-fixtures && npm run unit-tests && npm run api-tests && npm run grammar-tests && npm run regression-tests && npm run hostile-env-tests",
|
||||
"analyze-coverage": "istanbul cover test/unit-tests.js",
|
||||
"api-tests": "mocha -R dot test/api-tests.js",
|
||||
"appveyor": "npm run compile && npm run all-tests && npm run browser-tests",
|
||||
"benchmark": "npm run benchmark-parser && npm run benchmark-tokenizer",
|
||||
"benchmark-parser": "node -expose_gc test/benchmark-parser.js",
|
||||
"benchmark-tokenizer": "node --expose_gc test/benchmark-tokenizer.js",
|
||||
"browser-tests": "npm run compile && npm run generate-fixtures && cd test && karma start --single-run",
|
||||
"check-coverage": "istanbul check-coverage --statement 100 --branch 100 --function 100",
|
||||
"check-version": "node test/check-version.js",
|
||||
"circleci": "npm test && npm run codecov && npm run downstream",
|
||||
"code-style": "tsfmt --verify src/*.ts && tsfmt --verify test/*.js",
|
||||
"codecov": "istanbul report cobertura && codecov < ./coverage/cobertura-coverage.xml",
|
||||
"compile": "tsc -p src/ && webpack && node tools/fixupbundle.js",
|
||||
"complexity": "node test/check-complexity.js",
|
||||
"downstream": "node test/downstream.js",
|
||||
"droneio": "npm run compile && npm run all-tests && npm run saucelabs",
|
||||
"dynamic-analysis": "npm run analyze-coverage && npm run check-coverage",
|
||||
"format-code": "tsfmt -r src/*.ts && tsfmt -r test/*.js",
|
||||
"generate-fixtures": "node tools/generate-fixtures.js",
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"generate-xhtml-entities": "node tools/generate-xhtml-entities.js",
|
||||
"grammar-tests": "node test/grammar-tests.js",
|
||||
"hostile-env-tests": "node test/hostile-environment-tests.js",
|
||||
"prepublish": "npm run compile",
|
||||
"profile": "node --prof test/profile.js && mv isolate*.log v8.log && node-tick-processor",
|
||||
"regression-tests": "node test/regression-tests.js",
|
||||
"saucelabs": "npm run saucelabs-evergreen && npm run saucelabs-ie && npm run saucelabs-safari",
|
||||
"saucelabs-evergreen": "cd test && karma start saucelabs-evergreen.conf.js",
|
||||
"saucelabs-ie": "cd test && karma start saucelabs-ie.conf.js",
|
||||
"saucelabs-safari": "cd test && karma start saucelabs-safari.conf.js",
|
||||
"static-analysis": "npm run check-version && npm run tslint && npm run code-style && npm run complexity",
|
||||
"test": "npm run compile && npm run all-tests && npm run static-analysis && npm run dynamic-analysis",
|
||||
"travis": "npm test",
|
||||
"tslint": "tslint src/*.ts",
|
||||
"unit-tests": "node test/unit-tests.js",
|
||||
"verify-line-ending": "node test/verify-line-ending.js"
|
||||
},
|
||||
"version": "4.0.1"
|
||||
}
|
43
bin/tags/node_modules/fs.realpath/LICENSE
generated
vendored
43
bin/tags/node_modules/fs.realpath/LICENSE
generated
vendored
@@ -1,43 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
----
|
||||
|
||||
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
|
||||
methods from Node.js v0.10 under the terms of the Node.js MIT license.
|
||||
|
||||
Node's license follows, also included at the header of `old.js` which contains
|
||||
the licensed code:
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
33
bin/tags/node_modules/fs.realpath/README.md
generated
vendored
33
bin/tags/node_modules/fs.realpath/README.md
generated
vendored
@@ -1,33 +0,0 @@
|
||||
# fs.realpath
|
||||
|
||||
A backwards-compatible fs.realpath for Node v6 and above
|
||||
|
||||
In Node v6, the JavaScript implementation of fs.realpath was replaced
|
||||
with a faster (but less resilient) native implementation. That raises
|
||||
new and platform-specific errors and cannot handle long or excessively
|
||||
symlink-looping paths.
|
||||
|
||||
This module handles those cases by detecting the new errors and
|
||||
falling back to the JavaScript implementation. On versions of Node
|
||||
prior to v6, it has no effect.
|
||||
|
||||
## USAGE
|
||||
|
||||
```js
|
||||
var rp = require('fs.realpath')
|
||||
|
||||
// async version
|
||||
rp.realpath(someLongAndLoopingPath, function (er, real) {
|
||||
// the ELOOP was handled, but it was a bit slower
|
||||
})
|
||||
|
||||
// sync version
|
||||
var real = rp.realpathSync(someLongAndLoopingPath)
|
||||
|
||||
// monkeypatch at your own risk!
|
||||
// This replaces the fs.realpath/fs.realpathSync builtins
|
||||
rp.monkeypatch()
|
||||
|
||||
// un-do the monkeypatching
|
||||
rp.unmonkeypatch()
|
||||
```
|
66
bin/tags/node_modules/fs.realpath/index.js
generated
vendored
66
bin/tags/node_modules/fs.realpath/index.js
generated
vendored
@@ -1,66 +0,0 @@
|
||||
module.exports = realpath
|
||||
realpath.realpath = realpath
|
||||
realpath.sync = realpathSync
|
||||
realpath.realpathSync = realpathSync
|
||||
realpath.monkeypatch = monkeypatch
|
||||
realpath.unmonkeypatch = unmonkeypatch
|
||||
|
||||
var fs = require('fs')
|
||||
var origRealpath = fs.realpath
|
||||
var origRealpathSync = fs.realpathSync
|
||||
|
||||
var version = process.version
|
||||
var ok = /^v[0-5]\./.test(version)
|
||||
var old = require('./old.js')
|
||||
|
||||
function newError (er) {
|
||||
return er && er.syscall === 'realpath' && (
|
||||
er.code === 'ELOOP' ||
|
||||
er.code === 'ENOMEM' ||
|
||||
er.code === 'ENAMETOOLONG'
|
||||
)
|
||||
}
|
||||
|
||||
function realpath (p, cache, cb) {
|
||||
if (ok) {
|
||||
return origRealpath(p, cache, cb)
|
||||
}
|
||||
|
||||
if (typeof cache === 'function') {
|
||||
cb = cache
|
||||
cache = null
|
||||
}
|
||||
origRealpath(p, cache, function (er, result) {
|
||||
if (newError(er)) {
|
||||
old.realpath(p, cache, cb)
|
||||
} else {
|
||||
cb(er, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function realpathSync (p, cache) {
|
||||
if (ok) {
|
||||
return origRealpathSync(p, cache)
|
||||
}
|
||||
|
||||
try {
|
||||
return origRealpathSync(p, cache)
|
||||
} catch (er) {
|
||||
if (newError(er)) {
|
||||
return old.realpathSync(p, cache)
|
||||
} else {
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function monkeypatch () {
|
||||
fs.realpath = realpath
|
||||
fs.realpathSync = realpathSync
|
||||
}
|
||||
|
||||
function unmonkeypatch () {
|
||||
fs.realpath = origRealpath
|
||||
fs.realpathSync = origRealpathSync
|
||||
}
|
303
bin/tags/node_modules/fs.realpath/old.js
generated
vendored
303
bin/tags/node_modules/fs.realpath/old.js
generated
vendored
@@ -1,303 +0,0 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var pathModule = require('path');
|
||||
var isWindows = process.platform === 'win32';
|
||||
var fs = require('fs');
|
||||
|
||||
// JavaScript implementation of realpath, ported from node pre-v6
|
||||
|
||||
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
||||
|
||||
function rethrow() {
|
||||
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
|
||||
// is fairly slow to generate.
|
||||
var callback;
|
||||
if (DEBUG) {
|
||||
var backtrace = new Error;
|
||||
callback = debugCallback;
|
||||
} else
|
||||
callback = missingCallback;
|
||||
|
||||
return callback;
|
||||
|
||||
function debugCallback(err) {
|
||||
if (err) {
|
||||
backtrace.message = err.message;
|
||||
err = backtrace;
|
||||
missingCallback(err);
|
||||
}
|
||||
}
|
||||
|
||||
function missingCallback(err) {
|
||||
if (err) {
|
||||
if (process.throwDeprecation)
|
||||
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
||||
else if (!process.noDeprecation) {
|
||||
var msg = 'fs: missing callback ' + (err.stack || err.message);
|
||||
if (process.traceDeprecation)
|
||||
console.trace(msg);
|
||||
else
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function maybeCallback(cb) {
|
||||
return typeof cb === 'function' ? cb : rethrow();
|
||||
}
|
||||
|
||||
var normalize = pathModule.normalize;
|
||||
|
||||
// Regexp that finds the next partion of a (partial) path
|
||||
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
||||
if (isWindows) {
|
||||
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
||||
} else {
|
||||
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
||||
}
|
||||
|
||||
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
||||
if (isWindows) {
|
||||
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
||||
} else {
|
||||
var splitRootRe = /^[\/]*/;
|
||||
}
|
||||
|
||||
exports.realpathSync = function realpathSync(p, cache) {
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return cache[p];
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstatSync(base);
|
||||
knownHard[base] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
// NB: p.length changes.
|
||||
while (pos < p.length) {
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var resolvedLink;
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// some known symbolic link. no need to stat again.
|
||||
resolvedLink = cache[base];
|
||||
} else {
|
||||
var stat = fs.lstatSync(base);
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
continue;
|
||||
}
|
||||
|
||||
// read the link if it wasn't read before
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
var linkTarget = null;
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
linkTarget = seenLinks[id];
|
||||
}
|
||||
}
|
||||
if (linkTarget === null) {
|
||||
fs.statSync(base);
|
||||
linkTarget = fs.readlinkSync(base);
|
||||
}
|
||||
resolvedLink = pathModule.resolve(previous, linkTarget);
|
||||
// track this, if given a cache.
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
if (!isWindows) seenLinks[id] = linkTarget;
|
||||
}
|
||||
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
|
||||
if (cache) cache[original] = p;
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
exports.realpath = function realpath(p, cache, cb) {
|
||||
if (typeof cb !== 'function') {
|
||||
cb = maybeCallback(cache);
|
||||
cache = null;
|
||||
}
|
||||
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return process.nextTick(cb.bind(null, null, cache[p]));
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
knownHard[base] = true;
|
||||
LOOP();
|
||||
});
|
||||
} else {
|
||||
process.nextTick(LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
function LOOP() {
|
||||
// stop if scanned past end of path
|
||||
if (pos >= p.length) {
|
||||
if (cache) cache[original] = p;
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// known symbolic link. no need to stat again.
|
||||
return gotResolvedLink(cache[base]);
|
||||
}
|
||||
|
||||
return fs.lstat(base, gotStat);
|
||||
}
|
||||
|
||||
function gotStat(err, stat) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// if not a symlink, skip to the next path part
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
// stat & read the link if not read before
|
||||
// call gotTarget as soon as the link target is known
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
return gotTarget(null, seenLinks[id], base);
|
||||
}
|
||||
}
|
||||
fs.stat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fs.readlink(base, function(err, target) {
|
||||
if (!isWindows) seenLinks[id] = target;
|
||||
gotTarget(err, target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function gotTarget(err, target, base) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var resolvedLink = pathModule.resolve(previous, target);
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
gotResolvedLink(resolvedLink);
|
||||
}
|
||||
|
||||
function gotResolvedLink(resolvedLink) {
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
};
|
59
bin/tags/node_modules/fs.realpath/package.json
generated
vendored
59
bin/tags/node_modules/fs.realpath/package.json
generated
vendored
@@ -1,59 +0,0 @@
|
||||
{
|
||||
"_from": "fs.realpath@^1.0.0",
|
||||
"_id": "fs.realpath@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"_location": "/fs.realpath",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "fs.realpath@^1.0.0",
|
||||
"name": "fs.realpath",
|
||||
"escapedName": "fs.realpath",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"_shasum": "1504ad2523158caa40db4a2787cb01411994ea4f",
|
||||
"_spec": "fs.realpath@^1.0.0",
|
||||
"_where": "/home/ryan/Documents/node_modules/glob",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/fs.realpath/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails",
|
||||
"devDependencies": {},
|
||||
"files": [
|
||||
"old.js",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/fs.realpath#readme",
|
||||
"keywords": [
|
||||
"realpath",
|
||||
"fs",
|
||||
"polyfill"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "fs.realpath",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/fs.realpath.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --cov"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
21
bin/tags/node_modules/glob/LICENSE
generated
vendored
21
bin/tags/node_modules/glob/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
## Glob Logo
|
||||
|
||||
Glob's logo created by Tanya Brassie <http://tanyabrassie.com/>, licensed
|
||||
under a Creative Commons Attribution-ShareAlike 4.0 International License
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
375
bin/tags/node_modules/glob/README.md
generated
vendored
375
bin/tags/node_modules/glob/README.md
generated
vendored
@@ -1,375 +0,0 @@
|
||||
# Glob
|
||||
|
||||
Match files using the patterns the shell uses, like stars and stuff.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-glob/) [](https://ci.appveyor.com/project/isaacs/node-glob) [](https://coveralls.io/github/isaacs/node-glob?branch=master)
|
||||
|
||||
This is a glob implementation in JavaScript. It uses the `minimatch`
|
||||
library to do its matching.
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Install with npm
|
||||
|
||||
```
|
||||
npm i glob
|
||||
```
|
||||
|
||||
```javascript
|
||||
var glob = require("glob")
|
||||
|
||||
// options is optional
|
||||
glob("**/*.js", options, function (er, files) {
|
||||
// files is an array of filenames.
|
||||
// If the `nonull` option is set, and nothing
|
||||
// was found, then files is ["**/*.js"]
|
||||
// er is an error object or null.
|
||||
})
|
||||
```
|
||||
|
||||
## Glob Primer
|
||||
|
||||
"Globs" are the patterns you type when you do stuff like `ls *.js` on
|
||||
the command line, or put `build/*` in a `.gitignore` file.
|
||||
|
||||
Before parsing the path part patterns, braced sections are expanded
|
||||
into a set. Braced sections start with `{` and end with `}`, with any
|
||||
number of comma-delimited sections within. Braced sections may contain
|
||||
slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`.
|
||||
|
||||
The following characters have special magic meaning when used in a
|
||||
path portion:
|
||||
|
||||
* `*` Matches 0 or more characters in a single path portion
|
||||
* `?` Matches 1 character
|
||||
* `[...]` Matches a range of characters, similar to a RegExp range.
|
||||
If the first character of the range is `!` or `^` then it matches
|
||||
any character not in the range.
|
||||
* `!(pattern|pattern|pattern)` Matches anything that does not match
|
||||
any of the patterns provided.
|
||||
* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the
|
||||
patterns provided.
|
||||
* `+(pattern|pattern|pattern)` Matches one or more occurrences of the
|
||||
patterns provided.
|
||||
* `*(a|b|c)` Matches zero or more occurrences of the patterns provided
|
||||
* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns
|
||||
provided
|
||||
* `**` If a "globstar" is alone in a path portion, then it matches
|
||||
zero or more directories and subdirectories searching for matches.
|
||||
It does not crawl symlinked directories.
|
||||
|
||||
### Dots
|
||||
|
||||
If a file or directory path portion has a `.` as the first character,
|
||||
then it will not match any glob pattern unless that pattern's
|
||||
corresponding path part also has a `.` as its first character.
|
||||
|
||||
For example, the pattern `a/.*/c` would match the file at `a/.b/c`.
|
||||
However the pattern `a/*/c` would not, because `*` does not start with
|
||||
a dot character.
|
||||
|
||||
You can make glob treat dots as normal characters by setting
|
||||
`dot:true` in the options.
|
||||
|
||||
### Basename Matching
|
||||
|
||||
If you set `matchBase:true` in the options, and the pattern has no
|
||||
slashes in it, then it will seek for any file anywhere in the tree
|
||||
with a matching basename. For example, `*.js` would match
|
||||
`test/simple/basic.js`.
|
||||
|
||||
### Empty Sets
|
||||
|
||||
If no matching files are found, then an empty array is returned. This
|
||||
differs from the shell, where the pattern itself is returned. For
|
||||
example:
|
||||
|
||||
$ echo a*s*d*f
|
||||
a*s*d*f
|
||||
|
||||
To get the bash-style behavior, set the `nonull:true` in the options.
|
||||
|
||||
### See Also:
|
||||
|
||||
* `man sh`
|
||||
* `man bash` (Search for "Pattern Matching")
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
* [minimatch documentation](https://github.com/isaacs/minimatch)
|
||||
|
||||
## glob.hasMagic(pattern, [options])
|
||||
|
||||
Returns `true` if there are any special characters in the pattern, and
|
||||
`false` otherwise.
|
||||
|
||||
Note that the options affect the results. If `noext:true` is set in
|
||||
the options object, then `+(a|b)` will not be considered a magic
|
||||
pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`
|
||||
then that is considered magical, unless `nobrace:true` is set in the
|
||||
options.
|
||||
|
||||
## glob(pattern, [options], cb)
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}`
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform an asynchronous glob search.
|
||||
|
||||
## glob.sync(pattern, [options])
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* return: `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform a synchronous glob search.
|
||||
|
||||
## Class: glob.Glob
|
||||
|
||||
Create a Glob object by instantiating the `glob.Glob` class.
|
||||
|
||||
```javascript
|
||||
var Glob = require("glob").Glob
|
||||
var mg = new Glob(pattern, options, cb)
|
||||
```
|
||||
|
||||
It's an EventEmitter, and starts walking the filesystem to find matches
|
||||
immediately.
|
||||
|
||||
### new glob.Glob(pattern, [options], [cb])
|
||||
|
||||
* `pattern` `{String}` pattern to search for
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}` Called when an error occurs, or matches are found
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Note that if the `sync` flag is set in the options, then matches will
|
||||
be immediately available on the `g.found` member.
|
||||
|
||||
### Properties
|
||||
|
||||
* `minimatch` The minimatch object that the glob uses.
|
||||
* `options` The options object passed in.
|
||||
* `aborted` Boolean which is set to true when calling `abort()`. There
|
||||
is no way at this time to continue a glob search after aborting, but
|
||||
you can re-use the statCache to avoid having to duplicate syscalls.
|
||||
* `cache` Convenience object. Each field has the following possible
|
||||
values:
|
||||
* `false` - Path does not exist
|
||||
* `true` - Path exists
|
||||
* `'FILE'` - Path exists, and is not a directory
|
||||
* `'DIR'` - Path exists, and is a directory
|
||||
* `[file, entries, ...]` - Path exists, is a directory, and the
|
||||
array value is the results of `fs.readdir`
|
||||
* `statCache` Cache of `fs.stat` results, to prevent statting the same
|
||||
path multiple times.
|
||||
* `symlinks` A record of which paths are symbolic links, which is
|
||||
relevant in resolving `**` patterns.
|
||||
* `realpathCache` An optional object which is passed to `fs.realpath`
|
||||
to minimize unnecessary syscalls. It is stored on the instantiated
|
||||
Glob object, and may be re-used.
|
||||
|
||||
### Events
|
||||
|
||||
* `end` When the matching is finished, this is emitted with all the
|
||||
matches found. If the `nonull` option is set, and no match was found,
|
||||
then the `matches` list contains the original pattern. The matches
|
||||
are sorted, unless the `nosort` flag is set.
|
||||
* `match` Every time a match is found, this is emitted with the specific
|
||||
thing that matched. It is not deduplicated or resolved to a realpath.
|
||||
* `error` Emitted when an unexpected error is encountered, or whenever
|
||||
any fs error occurs if `options.strict` is set.
|
||||
* `abort` When `abort()` is called, this event is raised.
|
||||
|
||||
### Methods
|
||||
|
||||
* `pause` Temporarily stop the search
|
||||
* `resume` Resume the search
|
||||
* `abort` Stop the search forever
|
||||
|
||||
### Options
|
||||
|
||||
All the options that can be passed to Minimatch can also be passed to
|
||||
Glob to change pattern matching behavior. Also, some have been added,
|
||||
or have glob-specific ramifications.
|
||||
|
||||
All options are false by default, unless otherwise noted.
|
||||
|
||||
All options are added to the Glob object, as well.
|
||||
|
||||
If you are running many `glob` operations, you can pass a Glob object
|
||||
as the `options` argument to a subsequent operation to shortcut some
|
||||
`stat` and `readdir` calls. At the very least, you may pass in shared
|
||||
`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that
|
||||
parallel glob operations will be sped up by sharing information about
|
||||
the filesystem.
|
||||
|
||||
* `cwd` The current working directory in which to search. Defaults
|
||||
to `process.cwd()`.
|
||||
* `root` The place where patterns starting with `/` will be mounted
|
||||
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
|
||||
systems, and `C:\` or some such on Windows.)
|
||||
* `dot` Include `.dot` files in normal matches and `globstar` matches.
|
||||
Note that an explicit dot in a portion of the pattern will always
|
||||
match dot files.
|
||||
* `nomount` By default, a pattern starting with a forward-slash will be
|
||||
"mounted" onto the root setting, so that a valid filesystem path is
|
||||
returned. Set this flag to disable that behavior.
|
||||
* `mark` Add a `/` character to directory matches. Note that this
|
||||
requires additional stat calls.
|
||||
* `nosort` Don't sort the results.
|
||||
* `stat` Set to true to stat *all* results. This reduces performance
|
||||
somewhat, and is completely unnecessary, unless `readdir` is presumed
|
||||
to be an untrustworthy indicator of file existence.
|
||||
* `silent` When an unusual error is encountered when attempting to
|
||||
read a directory, a warning will be printed to stderr. Set the
|
||||
`silent` option to true to suppress these warnings.
|
||||
* `strict` When an unusual error is encountered when attempting to
|
||||
read a directory, the process will just continue on in search of
|
||||
other matches. Set the `strict` option to raise an error in these
|
||||
cases.
|
||||
* `cache` See `cache` property above. Pass in a previously generated
|
||||
cache object to save some fs calls.
|
||||
* `statCache` A cache of results of filesystem information, to prevent
|
||||
unnecessary stat calls. While it should not normally be necessary
|
||||
to set this, you may pass the statCache from one glob() call to the
|
||||
options object of another, if you know that the filesystem will not
|
||||
change between calls. (See "Race Conditions" below.)
|
||||
* `symlinks` A cache of known symbolic links. You may pass in a
|
||||
previously generated `symlinks` object to save `lstat` calls when
|
||||
resolving `**` matches.
|
||||
* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead.
|
||||
* `nounique` In some cases, brace-expanded patterns can result in the
|
||||
same file showing up multiple times in the result set. By default,
|
||||
this implementation prevents duplicates in the result set. Set this
|
||||
flag to disable that behavior.
|
||||
* `nonull` Set to never return an empty set, instead returning a set
|
||||
containing the pattern itself. This is the default in glob(3).
|
||||
* `debug` Set to enable debug logging in minimatch and glob.
|
||||
* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets.
|
||||
* `noglobstar` Do not match `**` against multiple filenames. (Ie,
|
||||
treat it as a normal `*` instead.)
|
||||
* `noext` Do not match `+(a|b)` "extglob" patterns.
|
||||
* `nocase` Perform a case-insensitive match. Note: on
|
||||
case-insensitive filesystems, non-magic patterns will match by
|
||||
default, since `stat` and `readdir` will not raise errors.
|
||||
* `matchBase` Perform a basename-only match if the pattern does not
|
||||
contain any slash characters. That is, `*.js` would be treated as
|
||||
equivalent to `**/*.js`, matching all js files in all directories.
|
||||
* `nodir` Do not match directories, only files. (Note: to match
|
||||
*only* directories, simply put a `/` at the end of the pattern.)
|
||||
* `ignore` Add a pattern or an array of glob patterns to exclude matches.
|
||||
Note: `ignore` patterns are *always* in `dot:true` mode, regardless
|
||||
of any other settings.
|
||||
* `follow` Follow symlinked directories when expanding `**` patterns.
|
||||
Note that this can result in a lot of duplicate references in the
|
||||
presence of cyclic links.
|
||||
* `realpath` Set to true to call `fs.realpath` on all of the results.
|
||||
In the case of a symlink that cannot be resolved, the full absolute
|
||||
path to the matched entry is returned (though it will usually be a
|
||||
broken symlink)
|
||||
* `absolute` Set to true to always receive absolute paths for matched
|
||||
files. Unlike `realpath`, this also affects the values returned in
|
||||
the `match` event.
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between node-glob and other
|
||||
implementations, and are intentional.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.3, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
Note that symlinked directories are not crawled as part of a `**`,
|
||||
though their contents may match against subsequent portions of the
|
||||
pattern. This prevents infinite loops and duplicates and the like.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then glob returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
|
||||
### Comments and Negation
|
||||
|
||||
Previously, this module let you mark a pattern as a "comment" if it
|
||||
started with a `#` character, or a "negated" pattern if it started
|
||||
with a `!` character.
|
||||
|
||||
These options were deprecated in version 5, and removed in version 6.
|
||||
|
||||
To specify things that should not match, use the `ignore` option.
|
||||
|
||||
## Windows
|
||||
|
||||
**Please only use forward-slashes in glob expressions.**
|
||||
|
||||
Though windows uses either `/` or `\` as its path separator, only `/`
|
||||
characters are used by this glob implementation. You must use
|
||||
forward-slashes **only** in glob expressions. Back-slashes will always
|
||||
be interpreted as escape characters, not path separators.
|
||||
|
||||
Results from absolute patterns such as `/foo/*` are mounted onto the
|
||||
root setting using `path.join`. On windows, this will by default result
|
||||
in `/foo/*` matching `C:\foo\bar.txt`.
|
||||
|
||||
## Race Conditions
|
||||
|
||||
Glob searching, by its very nature, is susceptible to race conditions,
|
||||
since it relies on directory walking and such.
|
||||
|
||||
As a result, it is possible that a file that exists when glob looks for
|
||||
it may have been deleted or modified by the time it returns the result.
|
||||
|
||||
As part of its internal implementation, this program caches all stat
|
||||
and readdir calls that it makes, in order to cut down on system
|
||||
overhead. However, this also makes it even more susceptible to races,
|
||||
especially if the cache or statCache objects are reused between glob
|
||||
calls.
|
||||
|
||||
Users are thus advised not to use a glob result as a guarantee of
|
||||
filesystem state in the face of rapid changes. For the vast majority
|
||||
of operations, this is never a problem.
|
||||
|
||||
## Glob Logo
|
||||
Glob's logo was created by [Tanya Brassie](http://tanyabrassie.com/). Logo files can be found [here](https://github.com/isaacs/node-glob/tree/master/logo).
|
||||
|
||||
The logo is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
|
||||
|
||||
## Contributing
|
||||
|
||||
Any change to behavior (including bugfixes) must come with a test.
|
||||
|
||||
Patches that fail tests or reduce performance will be rejected.
|
||||
|
||||
```
|
||||
# to run tests
|
||||
npm test
|
||||
|
||||
# to re-generate test fixtures
|
||||
npm run test-regen
|
||||
|
||||
# to benchmark against bash/zsh
|
||||
npm run bench
|
||||
|
||||
# to profile javascript
|
||||
npm run prof
|
||||
```
|
||||
|
||||

|
67
bin/tags/node_modules/glob/changelog.md
generated
vendored
67
bin/tags/node_modules/glob/changelog.md
generated
vendored
@@ -1,67 +0,0 @@
|
||||
## 7.0
|
||||
|
||||
- Raise error if `options.cwd` is specified, and not a directory
|
||||
|
||||
## 6.0
|
||||
|
||||
- Remove comment and negation pattern support
|
||||
- Ignore patterns are always in `dot:true` mode
|
||||
|
||||
## 5.0
|
||||
|
||||
- Deprecate comment and negation patterns
|
||||
- Fix regression in `mark` and `nodir` options from making all cache
|
||||
keys absolute path.
|
||||
- Abort if `fs.readdir` returns an error that's unexpected
|
||||
- Don't emit `match` events for ignored items
|
||||
- Treat ENOTSUP like ENOTDIR in readdir
|
||||
|
||||
## 4.5
|
||||
|
||||
- Add `options.follow` to always follow directory symlinks in globstar
|
||||
- Add `options.realpath` to call `fs.realpath` on all results
|
||||
- Always cache based on absolute path
|
||||
|
||||
## 4.4
|
||||
|
||||
- Add `options.ignore`
|
||||
- Fix handling of broken symlinks
|
||||
|
||||
## 4.3
|
||||
|
||||
- Bump minimatch to 2.x
|
||||
- Pass all tests on Windows
|
||||
|
||||
## 4.2
|
||||
|
||||
- Add `glob.hasMagic` function
|
||||
- Add `options.nodir` flag
|
||||
|
||||
## 4.1
|
||||
|
||||
- Refactor sync and async implementations for performance
|
||||
- Throw if callback provided to sync glob function
|
||||
- Treat symbolic links in globstar results the same as Bash 4.3
|
||||
|
||||
## 4.0
|
||||
|
||||
- Use `^` for dependency versions (bumped major because this breaks
|
||||
older npm versions)
|
||||
- Ensure callbacks are only ever called once
|
||||
- switch to ISC license
|
||||
|
||||
## 3.x
|
||||
|
||||
- Rewrite in JavaScript
|
||||
- Add support for setting root, cwd, and windows support
|
||||
- Cache many fs calls
|
||||
- Add globstar support
|
||||
- emit match events
|
||||
|
||||
## 2.x
|
||||
|
||||
- Use `glob.h` and `fnmatch.h` from NetBSD
|
||||
|
||||
## 1.x
|
||||
|
||||
- `glob.h` static binding.
|
240
bin/tags/node_modules/glob/common.js
generated
vendored
240
bin/tags/node_modules/glob/common.js
generated
vendored
@@ -1,240 +0,0 @@
|
||||
exports.alphasort = alphasort
|
||||
exports.alphasorti = alphasorti
|
||||
exports.setopts = setopts
|
||||
exports.ownProp = ownProp
|
||||
exports.makeAbs = makeAbs
|
||||
exports.finish = finish
|
||||
exports.mark = mark
|
||||
exports.isIgnored = isIgnored
|
||||
exports.childrenIgnored = childrenIgnored
|
||||
|
||||
function ownProp (obj, field) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, field)
|
||||
}
|
||||
|
||||
var path = require("path")
|
||||
var minimatch = require("minimatch")
|
||||
var isAbsolute = require("path-is-absolute")
|
||||
var Minimatch = minimatch.Minimatch
|
||||
|
||||
function alphasorti (a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase())
|
||||
}
|
||||
|
||||
function alphasort (a, b) {
|
||||
return a.localeCompare(b)
|
||||
}
|
||||
|
||||
function setupIgnores (self, options) {
|
||||
self.ignore = options.ignore || []
|
||||
|
||||
if (!Array.isArray(self.ignore))
|
||||
self.ignore = [self.ignore]
|
||||
|
||||
if (self.ignore.length) {
|
||||
self.ignore = self.ignore.map(ignoreMap)
|
||||
}
|
||||
}
|
||||
|
||||
// ignore patterns are always in dot:true mode.
|
||||
function ignoreMap (pattern) {
|
||||
var gmatcher = null
|
||||
if (pattern.slice(-3) === '/**') {
|
||||
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
|
||||
gmatcher = new Minimatch(gpattern, { dot: true })
|
||||
}
|
||||
|
||||
return {
|
||||
matcher: new Minimatch(pattern, { dot: true }),
|
||||
gmatcher: gmatcher
|
||||
}
|
||||
}
|
||||
|
||||
function setopts (self, pattern, options) {
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
// base-matching: just use globstar for that.
|
||||
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
||||
if (options.noglobstar) {
|
||||
throw new Error("base matching requires globstar")
|
||||
}
|
||||
pattern = "**/" + pattern
|
||||
}
|
||||
|
||||
self.silent = !!options.silent
|
||||
self.pattern = pattern
|
||||
self.strict = options.strict !== false
|
||||
self.realpath = !!options.realpath
|
||||
self.realpathCache = options.realpathCache || Object.create(null)
|
||||
self.follow = !!options.follow
|
||||
self.dot = !!options.dot
|
||||
self.mark = !!options.mark
|
||||
self.nodir = !!options.nodir
|
||||
if (self.nodir)
|
||||
self.mark = true
|
||||
self.sync = !!options.sync
|
||||
self.nounique = !!options.nounique
|
||||
self.nonull = !!options.nonull
|
||||
self.nosort = !!options.nosort
|
||||
self.nocase = !!options.nocase
|
||||
self.stat = !!options.stat
|
||||
self.noprocess = !!options.noprocess
|
||||
self.absolute = !!options.absolute
|
||||
|
||||
self.maxLength = options.maxLength || Infinity
|
||||
self.cache = options.cache || Object.create(null)
|
||||
self.statCache = options.statCache || Object.create(null)
|
||||
self.symlinks = options.symlinks || Object.create(null)
|
||||
|
||||
setupIgnores(self, options)
|
||||
|
||||
self.changedCwd = false
|
||||
var cwd = process.cwd()
|
||||
if (!ownProp(options, "cwd"))
|
||||
self.cwd = cwd
|
||||
else {
|
||||
self.cwd = path.resolve(options.cwd)
|
||||
self.changedCwd = self.cwd !== cwd
|
||||
}
|
||||
|
||||
self.root = options.root || path.resolve(self.cwd, "/")
|
||||
self.root = path.resolve(self.root)
|
||||
if (process.platform === "win32")
|
||||
self.root = self.root.replace(/\\/g, "/")
|
||||
|
||||
// TODO: is an absolute `cwd` supposed to be resolved against `root`?
|
||||
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
|
||||
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
|
||||
if (process.platform === "win32")
|
||||
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
|
||||
self.nomount = !!options.nomount
|
||||
|
||||
// disable comments and negation in Minimatch.
|
||||
// Note that they are not supported in Glob itself anyway.
|
||||
options.nonegate = true
|
||||
options.nocomment = true
|
||||
|
||||
self.minimatch = new Minimatch(pattern, options)
|
||||
self.options = self.minimatch.options
|
||||
}
|
||||
|
||||
function finish (self) {
|
||||
var nou = self.nounique
|
||||
var all = nou ? [] : Object.create(null)
|
||||
|
||||
for (var i = 0, l = self.matches.length; i < l; i ++) {
|
||||
var matches = self.matches[i]
|
||||
if (!matches || Object.keys(matches).length === 0) {
|
||||
if (self.nonull) {
|
||||
// do like the shell, and spit out the literal glob
|
||||
var literal = self.minimatch.globSet[i]
|
||||
if (nou)
|
||||
all.push(literal)
|
||||
else
|
||||
all[literal] = true
|
||||
}
|
||||
} else {
|
||||
// had matches
|
||||
var m = Object.keys(matches)
|
||||
if (nou)
|
||||
all.push.apply(all, m)
|
||||
else
|
||||
m.forEach(function (m) {
|
||||
all[m] = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!nou)
|
||||
all = Object.keys(all)
|
||||
|
||||
if (!self.nosort)
|
||||
all = all.sort(self.nocase ? alphasorti : alphasort)
|
||||
|
||||
// at *some* point we statted all of these
|
||||
if (self.mark) {
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
all[i] = self._mark(all[i])
|
||||
}
|
||||
if (self.nodir) {
|
||||
all = all.filter(function (e) {
|
||||
var notDir = !(/\/$/.test(e))
|
||||
var c = self.cache[e] || self.cache[makeAbs(self, e)]
|
||||
if (notDir && c)
|
||||
notDir = c !== 'DIR' && !Array.isArray(c)
|
||||
return notDir
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (self.ignore.length)
|
||||
all = all.filter(function(m) {
|
||||
return !isIgnored(self, m)
|
||||
})
|
||||
|
||||
self.found = all
|
||||
}
|
||||
|
||||
function mark (self, p) {
|
||||
var abs = makeAbs(self, p)
|
||||
var c = self.cache[abs]
|
||||
var m = p
|
||||
if (c) {
|
||||
var isDir = c === 'DIR' || Array.isArray(c)
|
||||
var slash = p.slice(-1) === '/'
|
||||
|
||||
if (isDir && !slash)
|
||||
m += '/'
|
||||
else if (!isDir && slash)
|
||||
m = m.slice(0, -1)
|
||||
|
||||
if (m !== p) {
|
||||
var mabs = makeAbs(self, m)
|
||||
self.statCache[mabs] = self.statCache[abs]
|
||||
self.cache[mabs] = self.cache[abs]
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// lotta situps...
|
||||
function makeAbs (self, f) {
|
||||
var abs = f
|
||||
if (f.charAt(0) === '/') {
|
||||
abs = path.join(self.root, f)
|
||||
} else if (isAbsolute(f) || f === '') {
|
||||
abs = f
|
||||
} else if (self.changedCwd) {
|
||||
abs = path.resolve(self.cwd, f)
|
||||
} else {
|
||||
abs = path.resolve(f)
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
abs = abs.replace(/\\/g, '/')
|
||||
|
||||
return abs
|
||||
}
|
||||
|
||||
|
||||
// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
|
||||
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
|
||||
function isIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
|
||||
function childrenIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
790
bin/tags/node_modules/glob/glob.js
generated
vendored
790
bin/tags/node_modules/glob/glob.js
generated
vendored
@@ -1,790 +0,0 @@
|
||||
// Approach:
|
||||
//
|
||||
// 1. Get the minimatch set
|
||||
// 2. For each pattern in the set, PROCESS(pattern, false)
|
||||
// 3. Store matches per-set, then uniq them
|
||||
//
|
||||
// PROCESS(pattern, inGlobStar)
|
||||
// Get the first [n] items from pattern that are all strings
|
||||
// Join these together. This is PREFIX.
|
||||
// If there is no more remaining, then stat(PREFIX) and
|
||||
// add to matches if it succeeds. END.
|
||||
//
|
||||
// If inGlobStar and PREFIX is symlink and points to dir
|
||||
// set ENTRIES = []
|
||||
// else readdir(PREFIX) as ENTRIES
|
||||
// If fail, END
|
||||
//
|
||||
// with ENTRIES
|
||||
// If pattern[n] is GLOBSTAR
|
||||
// // handle the case where the globstar match is empty
|
||||
// // by pruning it out, and testing the resulting pattern
|
||||
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
|
||||
// // handle other cases.
|
||||
// for ENTRY in ENTRIES (not dotfiles)
|
||||
// // attach globstar + tail onto the entry
|
||||
// // Mark that this entry is a globstar match
|
||||
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
|
||||
//
|
||||
// else // not globstar
|
||||
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
|
||||
// Test ENTRY against pattern[n]
|
||||
// If fails, continue
|
||||
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
|
||||
//
|
||||
// Caveat:
|
||||
// Cache all stats and readdirs results to minimize syscall. Since all
|
||||
// we ever care about is existence and directory-ness, we can just keep
|
||||
// `true` for files, and [children,...] for directories, or `false` for
|
||||
// things that don't exist.
|
||||
|
||||
module.exports = glob
|
||||
|
||||
var fs = require('fs')
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var inherits = require('inherits')
|
||||
var EE = require('events').EventEmitter
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var globSync = require('./sync.js')
|
||||
var common = require('./common.js')
|
||||
var alphasort = common.alphasort
|
||||
var alphasorti = common.alphasorti
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var inflight = require('inflight')
|
||||
var util = require('util')
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
var once = require('once')
|
||||
|
||||
function glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') cb = options, options = {}
|
||||
if (!options) options = {}
|
||||
|
||||
if (options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return globSync(pattern, options)
|
||||
}
|
||||
|
||||
return new Glob(pattern, options, cb)
|
||||
}
|
||||
|
||||
glob.sync = globSync
|
||||
var GlobSync = glob.GlobSync = globSync.GlobSync
|
||||
|
||||
// old api surface
|
||||
glob.glob = glob
|
||||
|
||||
function extend (origin, add) {
|
||||
if (add === null || typeof add !== 'object') {
|
||||
return origin
|
||||
}
|
||||
|
||||
var keys = Object.keys(add)
|
||||
var i = keys.length
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]]
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
glob.hasMagic = function (pattern, options_) {
|
||||
var options = extend({}, options_)
|
||||
options.noprocess = true
|
||||
|
||||
var g = new Glob(pattern, options)
|
||||
var set = g.minimatch.set
|
||||
|
||||
if (!pattern)
|
||||
return false
|
||||
|
||||
if (set.length > 1)
|
||||
return true
|
||||
|
||||
for (var j = 0; j < set[0].length; j++) {
|
||||
if (typeof set[0][j] !== 'string')
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
glob.Glob = Glob
|
||||
inherits(Glob, EE)
|
||||
function Glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (options && options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return new GlobSync(pattern, options)
|
||||
}
|
||||
|
||||
if (!(this instanceof Glob))
|
||||
return new Glob(pattern, options, cb)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
this._didRealPath = false
|
||||
|
||||
// process each pattern in the minimatch set
|
||||
var n = this.minimatch.set.length
|
||||
|
||||
// The matches are stored as {<filename>: true,...} so that
|
||||
// duplicates are automagically pruned.
|
||||
// Later, we do an Object.keys() on these.
|
||||
// Keep them as a list so we can fill in when nonull is set.
|
||||
this.matches = new Array(n)
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
cb = once(cb)
|
||||
this.on('error', cb)
|
||||
this.on('end', function (matches) {
|
||||
cb(null, matches)
|
||||
})
|
||||
}
|
||||
|
||||
var self = this
|
||||
this._processing = 0
|
||||
|
||||
this._emitQueue = []
|
||||
this._processQueue = []
|
||||
this.paused = false
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
if (n === 0)
|
||||
return done()
|
||||
|
||||
var sync = true
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false, done)
|
||||
}
|
||||
sync = false
|
||||
|
||||
function done () {
|
||||
--self._processing
|
||||
if (self._processing <= 0) {
|
||||
if (sync) {
|
||||
process.nextTick(function () {
|
||||
self._finish()
|
||||
})
|
||||
} else {
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._finish = function () {
|
||||
assert(this instanceof Glob)
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (this.realpath && !this._didRealpath)
|
||||
return this._realpath()
|
||||
|
||||
common.finish(this)
|
||||
this.emit('end', this.found)
|
||||
}
|
||||
|
||||
Glob.prototype._realpath = function () {
|
||||
if (this._didRealpath)
|
||||
return
|
||||
|
||||
this._didRealpath = true
|
||||
|
||||
var n = this.matches.length
|
||||
if (n === 0)
|
||||
return this._finish()
|
||||
|
||||
var self = this
|
||||
for (var i = 0; i < this.matches.length; i++)
|
||||
this._realpathSet(i, next)
|
||||
|
||||
function next () {
|
||||
if (--n === 0)
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._realpathSet = function (index, cb) {
|
||||
var matchset = this.matches[index]
|
||||
if (!matchset)
|
||||
return cb()
|
||||
|
||||
var found = Object.keys(matchset)
|
||||
var self = this
|
||||
var n = found.length
|
||||
|
||||
if (n === 0)
|
||||
return cb()
|
||||
|
||||
var set = this.matches[index] = Object.create(null)
|
||||
found.forEach(function (p, i) {
|
||||
// If there's a problem with the stat, then it means that
|
||||
// one or more of the links in the realpath couldn't be
|
||||
// resolved. just return the abs value in that case.
|
||||
p = self._makeAbs(p)
|
||||
rp.realpath(p, self.realpathCache, function (er, real) {
|
||||
if (!er)
|
||||
set[real] = true
|
||||
else if (er.syscall === 'stat')
|
||||
set[p] = true
|
||||
else
|
||||
self.emit('error', er) // srsly wtf right here
|
||||
|
||||
if (--n === 0) {
|
||||
self.matches[index] = set
|
||||
cb()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
Glob.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
|
||||
Glob.prototype.abort = function () {
|
||||
this.aborted = true
|
||||
this.emit('abort')
|
||||
}
|
||||
|
||||
Glob.prototype.pause = function () {
|
||||
if (!this.paused) {
|
||||
this.paused = true
|
||||
this.emit('pause')
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype.resume = function () {
|
||||
if (this.paused) {
|
||||
this.emit('resume')
|
||||
this.paused = false
|
||||
if (this._emitQueue.length) {
|
||||
var eq = this._emitQueue.slice(0)
|
||||
this._emitQueue.length = 0
|
||||
for (var i = 0; i < eq.length; i ++) {
|
||||
var e = eq[i]
|
||||
this._emitMatch(e[0], e[1])
|
||||
}
|
||||
}
|
||||
if (this._processQueue.length) {
|
||||
var pq = this._processQueue.slice(0)
|
||||
this._processQueue.length = 0
|
||||
for (var i = 0; i < pq.length; i ++) {
|
||||
var p = pq[i]
|
||||
this._processing--
|
||||
this._process(p[0], p[1], p[2], p[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
|
||||
assert(this instanceof Glob)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
this._processing++
|
||||
if (this.paused) {
|
||||
this._processQueue.push([pattern, index, inGlobStar, cb])
|
||||
return
|
||||
}
|
||||
|
||||
//console.error('PROCESS %d', this._processing, pattern)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// see if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index, cb)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip _processing
|
||||
if (childrenIgnored(this, read))
|
||||
return cb()
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
//console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return cb()
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return cb()
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
this._process([e].concat(remain), index, inGlobStar, cb)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._emitMatch = function (index, e) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
if (this.paused) {
|
||||
this._emitQueue.push([index, e])
|
||||
return
|
||||
}
|
||||
|
||||
var abs = isAbsolute(e) ? e : this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute)
|
||||
e = abs
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
var st = this.statCache[abs]
|
||||
if (st)
|
||||
this.emit('stat', e, st)
|
||||
|
||||
this.emit('match', e)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirInGlobStar = function (abs, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false, cb)
|
||||
|
||||
var lstatkey = 'lstat\0' + abs
|
||||
var self = this
|
||||
var lstatcb = inflight(lstatkey, lstatcb_)
|
||||
|
||||
if (lstatcb)
|
||||
fs.lstat(abs, lstatcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (er && er.code === 'ENOENT')
|
||||
return cb()
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
self.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory()) {
|
||||
self.cache[abs] = 'FILE'
|
||||
cb()
|
||||
} else
|
||||
self._readdir(abs, false, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdir = function (abs, inGlobStar, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
|
||||
if (!cb)
|
||||
return
|
||||
|
||||
//console.error('RD %j %j', +inGlobStar, abs)
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs, cb)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return cb()
|
||||
|
||||
if (Array.isArray(c))
|
||||
return cb(null, c)
|
||||
}
|
||||
|
||||
var self = this
|
||||
fs.readdir(abs, readdirCb(this, abs, cb))
|
||||
}
|
||||
|
||||
function readdirCb (self, abs, cb) {
|
||||
return function (er, entries) {
|
||||
if (er)
|
||||
self._readdirError(abs, er, cb)
|
||||
else
|
||||
self._readdirEntries(abs, entries, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdirEntries = function (abs, entries, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
return cb(null, entries)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirError = function (f, er, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
this.emit('error', error)
|
||||
this.abort()
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict) {
|
||||
this.emit('error', er)
|
||||
// If the error is handled, then we abort
|
||||
// if not, we threw out of here
|
||||
this.abort()
|
||||
}
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
|
||||
return cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
//console.error('pgs2', prefix, remain[0], entries)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false, cb)
|
||||
|
||||
var isSym = this.symlinks[abs]
|
||||
var len = entries.length
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return cb()
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true, cb)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true, cb)
|
||||
}
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processSimple = function (prefix, index, cb) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var self = this
|
||||
this._stat(prefix, function (er, exists) {
|
||||
self._processSimple2(prefix, index, er, exists, cb)
|
||||
})
|
||||
}
|
||||
Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
|
||||
|
||||
//console.error('ps2', prefix, exists)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return cb()
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
cb()
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
Glob.prototype._stat = function (f, cb) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return cb()
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return cb(null, c)
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (stat !== undefined) {
|
||||
if (stat === false)
|
||||
return cb(null, stat)
|
||||
else {
|
||||
var type = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
if (needDir && type === 'FILE')
|
||||
return cb()
|
||||
else
|
||||
return cb(null, type, stat)
|
||||
}
|
||||
}
|
||||
|
||||
var self = this
|
||||
var statcb = inflight('stat\0' + abs, lstatcb_)
|
||||
if (statcb)
|
||||
fs.lstat(abs, statcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
// If it's a symlink, then treat it as the target, unless
|
||||
// the target does not exist, then treat it as a file.
|
||||
return fs.stat(abs, function (er, stat) {
|
||||
if (er)
|
||||
self._stat2(f, abs, null, lstat, cb)
|
||||
else
|
||||
self._stat2(f, abs, er, stat, cb)
|
||||
})
|
||||
} else {
|
||||
self._stat2(f, abs, er, lstat, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return cb()
|
||||
}
|
||||
|
||||
var needDir = f.slice(-1) === '/'
|
||||
this.statCache[abs] = stat
|
||||
|
||||
if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
|
||||
return cb(null, false, stat)
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
return cb(null, c, stat)
|
||||
}
|
80
bin/tags/node_modules/glob/package.json
generated
vendored
80
bin/tags/node_modules/glob/package.json
generated
vendored
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"_from": "glob",
|
||||
"_id": "glob@7.1.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"_location": "/glob",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "glob",
|
||||
"name": "glob",
|
||||
"escapedName": "glob",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"_shasum": "141f33b81a7c2492e125594307480c46679278a6",
|
||||
"_spec": "glob",
|
||||
"_where": "/home/ryan/Documents",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-glob/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "a little globber",
|
||||
"devDependencies": {
|
||||
"mkdirp": "0",
|
||||
"rimraf": "^2.2.8",
|
||||
"tap": "^12.0.1",
|
||||
"tick": "0.0.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"files": [
|
||||
"glob.js",
|
||||
"sync.js",
|
||||
"common.js"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/node-glob#readme",
|
||||
"license": "ISC",
|
||||
"main": "glob.js",
|
||||
"name": "glob",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/node-glob.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "bash benchmark.sh",
|
||||
"benchclean": "node benchclean.js",
|
||||
"prepublish": "npm run benchclean",
|
||||
"prof": "bash prof.sh && cat profile.txt",
|
||||
"profclean": "rm -f v8.log profile.txt",
|
||||
"test": "tap test/*.js --cov",
|
||||
"test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js"
|
||||
},
|
||||
"version": "7.1.6"
|
||||
}
|
486
bin/tags/node_modules/glob/sync.js
generated
vendored
486
bin/tags/node_modules/glob/sync.js
generated
vendored
@@ -1,486 +0,0 @@
|
||||
module.exports = globSync
|
||||
globSync.GlobSync = GlobSync
|
||||
|
||||
var fs = require('fs')
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var Glob = require('./glob.js').Glob
|
||||
var util = require('util')
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var common = require('./common.js')
|
||||
var alphasort = common.alphasort
|
||||
var alphasorti = common.alphasorti
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
function globSync (pattern, options) {
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
return new GlobSync(pattern, options).found
|
||||
}
|
||||
|
||||
function GlobSync (pattern, options) {
|
||||
if (!pattern)
|
||||
throw new Error('must provide pattern')
|
||||
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
if (!(this instanceof GlobSync))
|
||||
return new GlobSync(pattern, options)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
var n = this.minimatch.set.length
|
||||
this.matches = new Array(n)
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false)
|
||||
}
|
||||
this._finish()
|
||||
}
|
||||
|
||||
GlobSync.prototype._finish = function () {
|
||||
assert(this instanceof GlobSync)
|
||||
if (this.realpath) {
|
||||
var self = this
|
||||
this.matches.forEach(function (matchset, index) {
|
||||
var set = self.matches[index] = Object.create(null)
|
||||
for (var p in matchset) {
|
||||
try {
|
||||
p = self._makeAbs(p)
|
||||
var real = rp.realpathSync(p, self.realpathCache)
|
||||
set[real] = true
|
||||
} catch (er) {
|
||||
if (er.syscall === 'stat')
|
||||
set[self._makeAbs(p)] = true
|
||||
else
|
||||
throw er
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
common.finish(this)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._process = function (pattern, index, inGlobStar) {
|
||||
assert(this instanceof GlobSync)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// See if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip processing
|
||||
if (childrenIgnored(this, read))
|
||||
return
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix.slice(-1) !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix)
|
||||
newPattern = [prefix, e]
|
||||
else
|
||||
newPattern = [e]
|
||||
this._process(newPattern.concat(remain), index, inGlobStar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._emitMatch = function (index, e) {
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
var abs = this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute) {
|
||||
e = abs
|
||||
}
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
if (this.stat)
|
||||
this._stat(e)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._readdirInGlobStar = function (abs) {
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false)
|
||||
|
||||
var entries
|
||||
var lstat
|
||||
var stat
|
||||
try {
|
||||
lstat = fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er.code === 'ENOENT') {
|
||||
// lstat failed, doesn't exist
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
this.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory())
|
||||
this.cache[abs] = 'FILE'
|
||||
else
|
||||
entries = this._readdir(abs, false)
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdir = function (abs, inGlobStar) {
|
||||
var entries
|
||||
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return null
|
||||
|
||||
if (Array.isArray(c))
|
||||
return c
|
||||
}
|
||||
|
||||
try {
|
||||
return this._readdirEntries(abs, fs.readdirSync(abs))
|
||||
} catch (er) {
|
||||
this._readdirError(abs, er)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirEntries = function (abs, entries) {
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
|
||||
// mark and cache dir-ness
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirError = function (f, er) {
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
throw error
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict)
|
||||
throw er
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false)
|
||||
|
||||
var len = entries.length
|
||||
var isSym = this.symlinks[abs]
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true)
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processSimple = function (prefix, index) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var exists = this._stat(prefix)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
GlobSync.prototype._stat = function (f) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return false
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (!stat) {
|
||||
var lstat
|
||||
try {
|
||||
lstat = fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
try {
|
||||
stat = fs.statSync(abs)
|
||||
} catch (er) {
|
||||
stat = lstat
|
||||
}
|
||||
} else {
|
||||
stat = lstat
|
||||
}
|
||||
}
|
||||
|
||||
this.statCache[abs] = stat
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
GlobSync.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
GlobSync.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
15
bin/tags/node_modules/inflight/LICENSE
generated
vendored
15
bin/tags/node_modules/inflight/LICENSE
generated
vendored
@@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
37
bin/tags/node_modules/inflight/README.md
generated
vendored
37
bin/tags/node_modules/inflight/README.md
generated
vendored
@@ -1,37 +0,0 @@
|
||||
# inflight
|
||||
|
||||
Add callbacks to requests in flight to avoid async duplication
|
||||
|
||||
## USAGE
|
||||
|
||||
```javascript
|
||||
var inflight = require('inflight')
|
||||
|
||||
// some request that does some stuff
|
||||
function req(key, callback) {
|
||||
// key is any random string. like a url or filename or whatever.
|
||||
//
|
||||
// will return either a falsey value, indicating that the
|
||||
// request for this key is already in flight, or a new callback
|
||||
// which when called will call all callbacks passed to inflightk
|
||||
// with the same key
|
||||
callback = inflight(key, callback)
|
||||
|
||||
// If we got a falsey value back, then there's already a req going
|
||||
if (!callback) return
|
||||
|
||||
// this is where you'd fetch the url or whatever
|
||||
// callback is also once()-ified, so it can safely be assigned
|
||||
// to multiple events etc. First call wins.
|
||||
setTimeout(function() {
|
||||
callback(null, key)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// only assigns a single setTimeout
|
||||
// when it dings, all cbs get called
|
||||
req('foo', cb1)
|
||||
req('foo', cb2)
|
||||
req('foo', cb3)
|
||||
req('foo', cb4)
|
||||
```
|
54
bin/tags/node_modules/inflight/inflight.js
generated
vendored
54
bin/tags/node_modules/inflight/inflight.js
generated
vendored
@@ -1,54 +0,0 @@
|
||||
var wrappy = require('wrappy')
|
||||
var reqs = Object.create(null)
|
||||
var once = require('once')
|
||||
|
||||
module.exports = wrappy(inflight)
|
||||
|
||||
function inflight (key, cb) {
|
||||
if (reqs[key]) {
|
||||
reqs[key].push(cb)
|
||||
return null
|
||||
} else {
|
||||
reqs[key] = [cb]
|
||||
return makeres(key)
|
||||
}
|
||||
}
|
||||
|
||||
function makeres (key) {
|
||||
return once(function RES () {
|
||||
var cbs = reqs[key]
|
||||
var len = cbs.length
|
||||
var args = slice(arguments)
|
||||
|
||||
// XXX It's somewhat ambiguous whether a new callback added in this
|
||||
// pass should be queued for later execution if something in the
|
||||
// list of callbacks throws, or if it should just be discarded.
|
||||
// However, it's such an edge case that it hardly matters, and either
|
||||
// choice is likely as surprising as the other.
|
||||
// As it happens, we do go ahead and schedule it for later execution.
|
||||
try {
|
||||
for (var i = 0; i < len; i++) {
|
||||
cbs[i].apply(null, args)
|
||||
}
|
||||
} finally {
|
||||
if (cbs.length > len) {
|
||||
// added more in the interim.
|
||||
// de-zalgo, just in case, but don't call again.
|
||||
cbs.splice(0, len)
|
||||
process.nextTick(function () {
|
||||
RES.apply(null, args)
|
||||
})
|
||||
} else {
|
||||
delete reqs[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function slice (args) {
|
||||
var length = args.length
|
||||
var array = []
|
||||
|
||||
for (var i = 0; i < length; i++) array[i] = args[i]
|
||||
return array
|
||||
}
|
58
bin/tags/node_modules/inflight/package.json
generated
vendored
58
bin/tags/node_modules/inflight/package.json
generated
vendored
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"_from": "inflight@^1.0.4",
|
||||
"_id": "inflight@1.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"_location": "/inflight",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "inflight@^1.0.4",
|
||||
"name": "inflight",
|
||||
"escapedName": "inflight",
|
||||
"rawSpec": "^1.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"_shasum": "49bd6331d7d02d0c09bc910a1075ba8165b56df9",
|
||||
"_spec": "inflight@^1.0.4",
|
||||
"_where": "/home/ryan/Documents/node_modules/glob",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/inflight/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Add callbacks to requests in flight to avoid async duplication",
|
||||
"devDependencies": {
|
||||
"tap": "^7.1.2"
|
||||
},
|
||||
"files": [
|
||||
"inflight.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/inflight",
|
||||
"license": "ISC",
|
||||
"main": "inflight.js",
|
||||
"name": "inflight",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/inflight.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test.js --100"
|
||||
},
|
||||
"version": "1.0.6"
|
||||
}
|
16
bin/tags/node_modules/inherits/LICENSE
generated
vendored
16
bin/tags/node_modules/inherits/LICENSE
generated
vendored
@@ -1,16 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
42
bin/tags/node_modules/inherits/README.md
generated
vendored
42
bin/tags/node_modules/inherits/README.md
generated
vendored
@@ -1,42 +0,0 @@
|
||||
Browser-friendly inheritance fully compatible with standard node.js
|
||||
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
||||
|
||||
This package exports standard `inherits` from node.js `util` module in
|
||||
node environment, but also provides alternative browser-friendly
|
||||
implementation through [browser
|
||||
field](https://gist.github.com/shtylman/4339901). Alternative
|
||||
implementation is a literal copy of standard one located in standalone
|
||||
module to avoid requiring of `util`. It also has a shim for old
|
||||
browsers with no `Object.create` support.
|
||||
|
||||
While keeping you sure you are using standard `inherits`
|
||||
implementation in node.js environment, it allows bundlers such as
|
||||
[browserify](https://github.com/substack/node-browserify) to not
|
||||
include full `util` package to your client code if all you need is
|
||||
just `inherits` function. It worth, because browser shim for `util`
|
||||
package is large and `inherits` is often the single function you need
|
||||
from it.
|
||||
|
||||
It's recommended to use this package instead of
|
||||
`require('util').inherits` for any code that has chances to be used
|
||||
not only in node.js but in browser too.
|
||||
|
||||
## usage
|
||||
|
||||
```js
|
||||
var inherits = require('inherits');
|
||||
// then use exactly as the standard one
|
||||
```
|
||||
|
||||
## note on version ~1.0
|
||||
|
||||
Version ~1.0 had completely different motivation and is not compatible
|
||||
neither with 2.0 nor with standard node.js `inherits`.
|
||||
|
||||
If you are using version ~1.0 and planning to switch to ~2.0, be
|
||||
careful:
|
||||
|
||||
* new version uses `super_` instead of `super` for referencing
|
||||
superclass
|
||||
* new version overwrites current prototype while old one preserves any
|
||||
existing fields on it
|
9
bin/tags/node_modules/inherits/inherits.js
generated
vendored
9
bin/tags/node_modules/inherits/inherits.js
generated
vendored
@@ -1,9 +0,0 @@
|
||||
try {
|
||||
var util = require('util');
|
||||
/* istanbul ignore next */
|
||||
if (typeof util.inherits !== 'function') throw '';
|
||||
module.exports = util.inherits;
|
||||
} catch (e) {
|
||||
/* istanbul ignore next */
|
||||
module.exports = require('./inherits_browser.js');
|
||||
}
|
27
bin/tags/node_modules/inherits/inherits_browser.js
generated
vendored
27
bin/tags/node_modules/inherits/inherits_browser.js
generated
vendored
@@ -1,27 +0,0 @@
|
||||
if (typeof Object.create === 'function') {
|
||||
// implementation from standard node.js 'util' module
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// old school shim for old browsers
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
if (superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
}
|
||||
}
|
||||
}
|
61
bin/tags/node_modules/inherits/package.json
generated
vendored
61
bin/tags/node_modules/inherits/package.json
generated
vendored
@@ -1,61 +0,0 @@
|
||||
{
|
||||
"_from": "inherits@2",
|
||||
"_id": "inherits@2.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"_location": "/inherits",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "inherits@2",
|
||||
"name": "inherits",
|
||||
"escapedName": "inherits",
|
||||
"rawSpec": "2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"_shasum": "0fa2c64f932917c3433a0ded55363aae37416b7c",
|
||||
"_spec": "inherits@2",
|
||||
"_where": "/home/ryan/Documents/node_modules/glob",
|
||||
"browser": "./inherits_browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/inherits/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
||||
"devDependencies": {
|
||||
"tap": "^14.2.4"
|
||||
},
|
||||
"files": [
|
||||
"inherits.js",
|
||||
"inherits_browser.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/inherits#readme",
|
||||
"keywords": [
|
||||
"inheritance",
|
||||
"class",
|
||||
"klass",
|
||||
"oop",
|
||||
"object-oriented",
|
||||
"inherits",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "./inherits.js",
|
||||
"name": "inherits",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/inherits.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap"
|
||||
},
|
||||
"version": "2.0.4"
|
||||
}
|
551
bin/tags/node_modules/js-yaml/CHANGELOG.md
generated
vendored
551
bin/tags/node_modules/js-yaml/CHANGELOG.md
generated
vendored
@@ -1,551 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [3.14.0] - 2020-05-22
|
||||
### Changed
|
||||
- Support `safe/loadAll(input, options)` variant of call.
|
||||
- CI: drop outdated nodejs versions.
|
||||
- Dev deps bump.
|
||||
|
||||
### Fixed
|
||||
- Quote `=` in plain scalars #519.
|
||||
- Check the node type for `!<?>` tag in case user manually specifies it.
|
||||
- Verify that there are no null-bytes in input.
|
||||
- Fix wrong quote position when writing condensed flow, #526.
|
||||
|
||||
|
||||
## [3.13.1] - 2019-04-05
|
||||
### Security
|
||||
- Fix possible code execution in (already unsafe) `.load()`, #480.
|
||||
|
||||
|
||||
## [3.13.0] - 2019-03-20
|
||||
### Security
|
||||
- Security fix: `safeLoad()` can hang when arrays with nested refs
|
||||
used as key. Now throws exception for nested arrays. #475.
|
||||
|
||||
|
||||
## [3.12.2] - 2019-02-26
|
||||
### Fixed
|
||||
- Fix `noArrayIndent` option for root level, #468.
|
||||
|
||||
|
||||
## [3.12.1] - 2019-01-05
|
||||
### Added
|
||||
- Added `noArrayIndent` option, #432.
|
||||
|
||||
|
||||
## [3.12.0] - 2018-06-02
|
||||
### Changed
|
||||
- Support arrow functions without a block statement, #421.
|
||||
|
||||
|
||||
## [3.11.0] - 2018-03-05
|
||||
### Added
|
||||
- Add arrow functions suport for `!!js/function`.
|
||||
|
||||
### Fixed
|
||||
- Fix dump in bin/octal/hex formats for negative integers, #399.
|
||||
|
||||
|
||||
## [3.10.0] - 2017-09-10
|
||||
### Fixed
|
||||
- Fix `condenseFlow` output (quote keys for sure, instead of spaces), #371, #370.
|
||||
- Dump astrals as codepoints instead of surrogate pair, #368.
|
||||
|
||||
|
||||
## [3.9.1] - 2017-07-08
|
||||
### Fixed
|
||||
- Ensure stack is present for custom errors in node 7.+, #351.
|
||||
|
||||
|
||||
## [3.9.0] - 2017-07-08
|
||||
### Added
|
||||
- Add `condenseFlow` option (to create pretty URL query params), #346.
|
||||
|
||||
### Fixed
|
||||
- Support array return from safeLoadAll/loadAll, #350.
|
||||
|
||||
|
||||
## [3.8.4] - 2017-05-08
|
||||
### Fixed
|
||||
- Dumper: prevent space after dash for arrays that wrap, #343.
|
||||
|
||||
|
||||
## [3.8.3] - 2017-04-05
|
||||
### Fixed
|
||||
- Should not allow numbers to begin and end with underscore, #335.
|
||||
|
||||
|
||||
## [3.8.2] - 2017-03-02
|
||||
### Fixed
|
||||
- Fix `!!float 123` (integers) parse, #333.
|
||||
- Don't allow leading zeros in floats (except 0, 0.xxx).
|
||||
- Allow positive exponent without sign in floats.
|
||||
|
||||
|
||||
## [3.8.1] - 2017-02-07
|
||||
### Changed
|
||||
- Maintenance: update browserified build.
|
||||
|
||||
|
||||
## [3.8.0] - 2017-02-07
|
||||
### Fixed
|
||||
- Fix reported position for `duplicated mapping key` errors.
|
||||
Now points to block start instead of block end.
|
||||
(#243, thanks to @shockey).
|
||||
|
||||
|
||||
## [3.7.0] - 2016-11-12
|
||||
### Added
|
||||
- Support polymorphism for tags (#300, thanks to @monken).
|
||||
|
||||
### Fixed
|
||||
- Fix parsing of quotes followed by newlines (#304, thanks to @dplepage).
|
||||
|
||||
|
||||
## [3.6.1] - 2016-05-11
|
||||
### Fixed
|
||||
- Fix output cut on a pipe, #286.
|
||||
|
||||
|
||||
## [3.6.0] - 2016-04-16
|
||||
### Fixed
|
||||
- Dumper rewrite, fix multiple bugs with trailing `\n`.
|
||||
Big thanks to @aepsilon!
|
||||
- Loader: fix leading/trailing newlines in block scalars, @aepsilon.
|
||||
|
||||
|
||||
## [3.5.5] - 2016-03-17
|
||||
### Fixed
|
||||
- Date parse fix: don't allow dates with on digit in month and day, #268.
|
||||
|
||||
|
||||
## [3.5.4] - 2016-03-09
|
||||
### Added
|
||||
- `noCompatMode` for dumper, to disable quoting YAML 1.1 values.
|
||||
|
||||
|
||||
## [3.5.3] - 2016-02-11
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
|
||||
|
||||
## [3.5.2] - 2016-01-11
|
||||
### Changed
|
||||
- Maintenance: missed comma in bower config.
|
||||
|
||||
|
||||
## [3.5.1] - 2016-01-11
|
||||
### Changed
|
||||
- Removed `inherit` dependency, #239.
|
||||
- Better browserify workaround for esprima load.
|
||||
- Demo rewrite.
|
||||
|
||||
|
||||
## [3.5.0] - 2016-01-10
|
||||
### Fixed
|
||||
- Dumper. Fold strings only, #217.
|
||||
- Dumper. `norefs` option, to clone linked objects, #229.
|
||||
- Loader. Throw a warning for duplicate keys, #166.
|
||||
- Improved browserify support (mark `esprima` & `Buffer` excluded).
|
||||
|
||||
|
||||
## [3.4.6] - 2015-11-26
|
||||
### Changed
|
||||
- Use standalone `inherit` to keep browserified files clear.
|
||||
|
||||
|
||||
## [3.4.5] - 2015-11-23
|
||||
### Added
|
||||
- Added `lineWidth` option to dumper.
|
||||
|
||||
|
||||
## [3.4.4] - 2015-11-21
|
||||
### Fixed
|
||||
- Fixed floats dump (missed dot for scientific format), #220.
|
||||
- Allow non-printable characters inside quoted scalars, #192.
|
||||
|
||||
|
||||
## [3.4.3] - 2015-10-10
|
||||
### Changed
|
||||
- Maintenance release - deps bump (esprima, argparse).
|
||||
|
||||
|
||||
## [3.4.2] - 2015-09-09
|
||||
### Fixed
|
||||
- Fixed serialization of duplicated entries in sequences, #205.
|
||||
Thanks to @vogelsgesang.
|
||||
|
||||
|
||||
## [3.4.1] - 2015-09-05
|
||||
### Fixed
|
||||
- Fixed stacktrace handling in generated errors, for browsers (FF/IE).
|
||||
|
||||
|
||||
## [3.4.0] - 2015-08-23
|
||||
### Changed
|
||||
- Don't throw on warnings anymore. Use `onWarning` option to catch.
|
||||
- Throw error on unknown tags (was warning before).
|
||||
- Reworked internals of error class.
|
||||
|
||||
### Fixed
|
||||
- Fixed multiline keys dump, #197. Thanks to @tcr.
|
||||
- Fixed heading line breaks in some scalars (regression).
|
||||
|
||||
|
||||
## [3.3.1] - 2015-05-13
|
||||
### Added
|
||||
- Added `.sortKeys` dumper option, thanks to @rjmunro.
|
||||
|
||||
### Fixed
|
||||
- Fixed astral characters support, #191.
|
||||
|
||||
|
||||
## [3.3.0] - 2015-04-26
|
||||
### Changed
|
||||
- Significantly improved long strings formatting in dumper, thanks to @isaacs.
|
||||
- Strip BOM if exists.
|
||||
|
||||
|
||||
## [3.2.7] - 2015-02-19
|
||||
### Changed
|
||||
- Maintenance release.
|
||||
- Updated dependencies.
|
||||
- HISTORY.md -> CHANGELOG.md
|
||||
|
||||
|
||||
## [3.2.6] - 2015-02-07
|
||||
### Fixed
|
||||
- Fixed encoding of UTF-16 surrogate pairs. (e.g. "\U0001F431" CAT FACE).
|
||||
- Fixed demo dates dump (#113, thanks to @Hypercubed).
|
||||
|
||||
|
||||
## [3.2.5] - 2014-12-28
|
||||
### Fixed
|
||||
- Fixed resolving of all built-in types on empty nodes.
|
||||
- Fixed invalid warning on empty lines within quoted scalars and flow collections.
|
||||
- Fixed bug: Tag on an empty node didn't resolve in some cases.
|
||||
|
||||
|
||||
## [3.2.4] - 2014-12-19
|
||||
### Fixed
|
||||
- Fixed resolving of !!null tag on an empty node.
|
||||
|
||||
|
||||
## [3.2.3] - 2014-11-08
|
||||
### Fixed
|
||||
- Implemented dumping of objects with circular and cross references.
|
||||
- Partially fixed aliasing of constructed objects. (see issue #141 for details)
|
||||
|
||||
|
||||
## [3.2.2] - 2014-09-07
|
||||
### Fixed
|
||||
- Fixed infinite loop on unindented block scalars.
|
||||
- Rewritten base64 encode/decode in binary type, to keep code licence clear.
|
||||
|
||||
|
||||
## [3.2.1] - 2014-08-24
|
||||
### Fixed
|
||||
- Nothig new. Just fix npm publish error.
|
||||
|
||||
|
||||
## [3.2.0] - 2014-08-24
|
||||
### Added
|
||||
- Added input piping support to CLI.
|
||||
|
||||
### Fixed
|
||||
- Fixed typo, that could cause hand on initial indent (#139).
|
||||
|
||||
|
||||
## [3.1.0] - 2014-07-07
|
||||
### Changed
|
||||
- 1.5x-2x speed boost.
|
||||
- Removed deprecated `require('xxx.yml')` support.
|
||||
- Significant code cleanup and refactoring.
|
||||
- Internal API changed. If you used custom types - see updated examples.
|
||||
Others are not affected.
|
||||
- Even if the input string has no trailing line break character,
|
||||
it will be parsed as if it has one.
|
||||
- Added benchmark scripts.
|
||||
- Moved bower files to /dist folder
|
||||
- Bugfixes.
|
||||
|
||||
|
||||
## [3.0.2] - 2014-02-27
|
||||
### Fixed
|
||||
- Fixed bug: "constructor" string parsed as `null`.
|
||||
|
||||
|
||||
## [3.0.1] - 2013-12-22
|
||||
### Fixed
|
||||
- Fixed parsing of literal scalars. (issue #108)
|
||||
- Prevented adding unnecessary spaces in object dumps. (issue #68)
|
||||
- Fixed dumping of objects with very long (> 1024 in length) keys.
|
||||
|
||||
|
||||
## [3.0.0] - 2013-12-16
|
||||
### Changed
|
||||
- Refactored code. Changed API for custom types.
|
||||
- Removed output colors in CLI, dump json by default.
|
||||
- Removed big dependencies from browser version (esprima, buffer). Load `esprima` manually, if `!!js/function` needed. `!!bin` now returns Array in browser
|
||||
- AMD support.
|
||||
- Don't quote dumped strings because of `-` & `?` (if not first char).
|
||||
- __Deprecated__ loading yaml files via `require()`, as not recommended
|
||||
behaviour for node.
|
||||
|
||||
|
||||
## [2.1.3] - 2013-10-16
|
||||
### Fixed
|
||||
- Fix wrong loading of empty block scalars.
|
||||
|
||||
|
||||
## [2.1.2] - 2013-10-07
|
||||
### Fixed
|
||||
- Fix unwanted line breaks in folded scalars.
|
||||
|
||||
|
||||
## [2.1.1] - 2013-10-02
|
||||
### Fixed
|
||||
- Dumper now respects deprecated booleans syntax from YAML 1.0/1.1
|
||||
- Fixed reader bug in JSON-like sequences/mappings.
|
||||
|
||||
|
||||
## [2.1.0] - 2013-06-05
|
||||
### Added
|
||||
- Add standard YAML schemas: Failsafe (`FAILSAFE_SCHEMA`),
|
||||
JSON (`JSON_SCHEMA`) and Core (`CORE_SCHEMA`).
|
||||
- Add `skipInvalid` dumper option.
|
||||
|
||||
### Changed
|
||||
- Rename `DEFAULT_SCHEMA` to `DEFAULT_FULL_SCHEMA`
|
||||
and `SAFE_SCHEMA` to `DEFAULT_SAFE_SCHEMA`.
|
||||
- Use `safeLoad` for `require` extension.
|
||||
|
||||
### Fixed
|
||||
- Bug fix: export `NIL` constant from the public interface.
|
||||
|
||||
|
||||
## [2.0.5] - 2013-04-26
|
||||
### Security
|
||||
- Close security issue in !!js/function constructor.
|
||||
Big thanks to @nealpoole for security audit.
|
||||
|
||||
|
||||
## [2.0.4] - 2013-04-08
|
||||
### Changed
|
||||
- Updated .npmignore to reduce package size
|
||||
|
||||
|
||||
## [2.0.3] - 2013-02-26
|
||||
### Fixed
|
||||
- Fixed dumping of empty arrays ans objects. ([] and {} instead of null)
|
||||
|
||||
|
||||
## [2.0.2] - 2013-02-15
|
||||
### Fixed
|
||||
- Fixed input validation: tabs are printable characters.
|
||||
|
||||
|
||||
## [2.0.1] - 2013-02-09
|
||||
### Fixed
|
||||
- Fixed error, when options not passed to function cass
|
||||
|
||||
|
||||
## [2.0.0] - 2013-02-09
|
||||
### Changed
|
||||
- Full rewrite. New architecture. Fast one-stage parsing.
|
||||
- Changed custom types API.
|
||||
- Added YAML dumper.
|
||||
|
||||
|
||||
## [1.0.3] - 2012-11-05
|
||||
### Fixed
|
||||
- Fixed utf-8 files loading.
|
||||
|
||||
|
||||
## [1.0.2] - 2012-08-02
|
||||
### Fixed
|
||||
- Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44.
|
||||
- Fix timstamps incorectly parsed in local time when no time part specified.
|
||||
|
||||
|
||||
## [1.0.1] - 2012-07-07
|
||||
### Fixed
|
||||
- Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong.
|
||||
- Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46.
|
||||
|
||||
|
||||
## [1.0.0] - 2012-07-01
|
||||
### Changed
|
||||
- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore.
|
||||
Fixes #42.
|
||||
- `require(filename)` now returns a single document and throws an Error if
|
||||
file contains more than one document.
|
||||
- CLI was merged back from js-yaml.bin
|
||||
|
||||
|
||||
## [0.3.7] - 2012-02-28
|
||||
### Fixed
|
||||
- Fix export of `addConstructor()`. Closes #39.
|
||||
|
||||
|
||||
## [0.3.6] - 2012-02-22
|
||||
### Changed
|
||||
- Removed AMD parts - too buggy to use. Need help to rewrite from scratch
|
||||
|
||||
### Fixed
|
||||
- Removed YUI compressor warning (renamed `double` variable). Closes #40.
|
||||
|
||||
|
||||
## [0.3.5] - 2012-01-10
|
||||
### Fixed
|
||||
- Workagound for .npmignore fuckup under windows. Thanks to airportyh.
|
||||
|
||||
|
||||
## [0.3.4] - 2011-12-24
|
||||
### Fixed
|
||||
- Fixes str[] for oldIEs support.
|
||||
- Adds better has change support for browserified demo.
|
||||
- improves compact output of Error. Closes #33.
|
||||
|
||||
|
||||
## [0.3.3] - 2011-12-20
|
||||
### Added
|
||||
- adds `compact` stringification of Errors.
|
||||
|
||||
### Changed
|
||||
- jsyaml executable moved to separate module.
|
||||
|
||||
|
||||
## [0.3.2] - 2011-12-16
|
||||
### Added
|
||||
- Added jsyaml executable.
|
||||
- Added !!js/function support. Closes #12.
|
||||
|
||||
### Fixed
|
||||
- Fixes ug with block style scalars. Closes #26.
|
||||
- All sources are passing JSLint now.
|
||||
- Fixes bug in Safari. Closes #28.
|
||||
- Fixes bug in Opers. Closes #29.
|
||||
- Improves browser support. Closes #20.
|
||||
|
||||
|
||||
## [0.3.1] - 2011-11-18
|
||||
### Added
|
||||
- Added AMD support for browserified version.
|
||||
- Added permalinks for online demo YAML snippets. Now we have YPaste service, lol.
|
||||
- Added !!js/regexp and !!js/undefined types. Partially solves #12.
|
||||
|
||||
### Changed
|
||||
- Wrapped browserified js-yaml into closure.
|
||||
|
||||
### Fixed
|
||||
- Fixed the resolvement of non-specific tags. Closes #17.
|
||||
- Fixed !!set mapping.
|
||||
- Fixed month parse in dates. Closes #19.
|
||||
|
||||
|
||||
## [0.3.0] - 2011-11-09
|
||||
### Added
|
||||
- Added browserified version. Closes #13.
|
||||
- Added live demo of browserified version.
|
||||
- Ported some of the PyYAML tests. See #14.
|
||||
|
||||
### Fixed
|
||||
- Removed JS.Class dependency. Closes #3.
|
||||
- Fixed timestamp bug when fraction was given.
|
||||
|
||||
|
||||
## [0.2.2] - 2011-11-06
|
||||
### Fixed
|
||||
- Fixed crash on docs without ---. Closes #8.
|
||||
- Fixed multiline string parse
|
||||
- Fixed tests/comments for using array as key
|
||||
|
||||
|
||||
## [0.2.1] - 2011-11-02
|
||||
### Fixed
|
||||
- Fixed short file read (<4k). Closes #9.
|
||||
|
||||
|
||||
## [0.2.0] - 2011-11-02
|
||||
### Changed
|
||||
- First public release
|
||||
|
||||
|
||||
[3.14.0]: https://github.com/nodeca/js-yaml/compare/3.13.1...3.14.0
|
||||
[3.13.1]: https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1
|
||||
[3.13.0]: https://github.com/nodeca/js-yaml/compare/3.12.2...3.13.0
|
||||
[3.12.2]: https://github.com/nodeca/js-yaml/compare/3.12.1...3.12.2
|
||||
[3.12.1]: https://github.com/nodeca/js-yaml/compare/3.12.0...3.12.1
|
||||
[3.12.0]: https://github.com/nodeca/js-yaml/compare/3.11.0...3.12.0
|
||||
[3.11.0]: https://github.com/nodeca/js-yaml/compare/3.10.0...3.11.0
|
||||
[3.10.0]: https://github.com/nodeca/js-yaml/compare/3.9.1...3.10.0
|
||||
[3.9.1]: https://github.com/nodeca/js-yaml/compare/3.9.0...3.9.1
|
||||
[3.9.0]: https://github.com/nodeca/js-yaml/compare/3.8.4...3.9.0
|
||||
[3.8.4]: https://github.com/nodeca/js-yaml/compare/3.8.3...3.8.4
|
||||
[3.8.3]: https://github.com/nodeca/js-yaml/compare/3.8.2...3.8.3
|
||||
[3.8.2]: https://github.com/nodeca/js-yaml/compare/3.8.1...3.8.2
|
||||
[3.8.1]: https://github.com/nodeca/js-yaml/compare/3.8.0...3.8.1
|
||||
[3.8.0]: https://github.com/nodeca/js-yaml/compare/3.7.0...3.8.0
|
||||
[3.7.0]: https://github.com/nodeca/js-yaml/compare/3.6.1...3.7.0
|
||||
[3.6.1]: https://github.com/nodeca/js-yaml/compare/3.6.0...3.6.1
|
||||
[3.6.0]: https://github.com/nodeca/js-yaml/compare/3.5.5...3.6.0
|
||||
[3.5.5]: https://github.com/nodeca/js-yaml/compare/3.5.4...3.5.5
|
||||
[3.5.4]: https://github.com/nodeca/js-yaml/compare/3.5.3...3.5.4
|
||||
[3.5.3]: https://github.com/nodeca/js-yaml/compare/3.5.2...3.5.3
|
||||
[3.5.2]: https://github.com/nodeca/js-yaml/compare/3.5.1...3.5.2
|
||||
[3.5.1]: https://github.com/nodeca/js-yaml/compare/3.5.0...3.5.1
|
||||
[3.5.0]: https://github.com/nodeca/js-yaml/compare/3.4.6...3.5.0
|
||||
[3.4.6]: https://github.com/nodeca/js-yaml/compare/3.4.5...3.4.6
|
||||
[3.4.5]: https://github.com/nodeca/js-yaml/compare/3.4.4...3.4.5
|
||||
[3.4.4]: https://github.com/nodeca/js-yaml/compare/3.4.3...3.4.4
|
||||
[3.4.3]: https://github.com/nodeca/js-yaml/compare/3.4.2...3.4.3
|
||||
[3.4.2]: https://github.com/nodeca/js-yaml/compare/3.4.1...3.4.2
|
||||
[3.4.1]: https://github.com/nodeca/js-yaml/compare/3.4.0...3.4.1
|
||||
[3.4.0]: https://github.com/nodeca/js-yaml/compare/3.3.1...3.4.0
|
||||
[3.3.1]: https://github.com/nodeca/js-yaml/compare/3.3.0...3.3.1
|
||||
[3.3.0]: https://github.com/nodeca/js-yaml/compare/3.2.7...3.3.0
|
||||
[3.2.7]: https://github.com/nodeca/js-yaml/compare/3.2.6...3.2.7
|
||||
[3.2.6]: https://github.com/nodeca/js-yaml/compare/3.2.5...3.2.6
|
||||
[3.2.5]: https://github.com/nodeca/js-yaml/compare/3.2.4...3.2.5
|
||||
[3.2.4]: https://github.com/nodeca/js-yaml/compare/3.2.3...3.2.4
|
||||
[3.2.3]: https://github.com/nodeca/js-yaml/compare/3.2.2...3.2.3
|
||||
[3.2.2]: https://github.com/nodeca/js-yaml/compare/3.2.1...3.2.2
|
||||
[3.2.1]: https://github.com/nodeca/js-yaml/compare/3.2.0...3.2.1
|
||||
[3.2.0]: https://github.com/nodeca/js-yaml/compare/3.1.0...3.2.0
|
||||
[3.1.0]: https://github.com/nodeca/js-yaml/compare/3.0.2...3.1.0
|
||||
[3.0.2]: https://github.com/nodeca/js-yaml/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/nodeca/js-yaml/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/nodeca/js-yaml/compare/2.1.3...3.0.0
|
||||
[2.1.3]: https://github.com/nodeca/js-yaml/compare/2.1.2...2.1.3
|
||||
[2.1.2]: https://github.com/nodeca/js-yaml/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/nodeca/js-yaml/compare/2.1.0...2.1.1
|
||||
[2.1.0]: https://github.com/nodeca/js-yaml/compare/2.0.5...2.1.0
|
||||
[2.0.5]: https://github.com/nodeca/js-yaml/compare/2.0.4...2.0.5
|
||||
[2.0.4]: https://github.com/nodeca/js-yaml/compare/2.0.3...2.0.4
|
||||
[2.0.3]: https://github.com/nodeca/js-yaml/compare/2.0.2...2.0.3
|
||||
[2.0.2]: https://github.com/nodeca/js-yaml/compare/2.0.1...2.0.2
|
||||
[2.0.1]: https://github.com/nodeca/js-yaml/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/nodeca/js-yaml/compare/1.0.3...2.0.0
|
||||
[1.0.3]: https://github.com/nodeca/js-yaml/compare/1.0.2...1.0.3
|
||||
[1.0.2]: https://github.com/nodeca/js-yaml/compare/1.0.1...1.0.2
|
||||
[1.0.1]: https://github.com/nodeca/js-yaml/compare/1.0.0...1.0.1
|
||||
[1.0.0]: https://github.com/nodeca/js-yaml/compare/0.3.7...1.0.0
|
||||
[0.3.7]: https://github.com/nodeca/js-yaml/compare/0.3.6...0.3.7
|
||||
[0.3.6]: https://github.com/nodeca/js-yaml/compare/0.3.5...0.3.6
|
||||
[0.3.5]: https://github.com/nodeca/js-yaml/compare/0.3.4...0.3.5
|
||||
[0.3.4]: https://github.com/nodeca/js-yaml/compare/0.3.3...0.3.4
|
||||
[0.3.3]: https://github.com/nodeca/js-yaml/compare/0.3.2...0.3.3
|
||||
[0.3.2]: https://github.com/nodeca/js-yaml/compare/0.3.1...0.3.2
|
||||
[0.3.1]: https://github.com/nodeca/js-yaml/compare/0.3.0...0.3.1
|
||||
[0.3.0]: https://github.com/nodeca/js-yaml/compare/0.2.2...0.3.0
|
||||
[0.2.2]: https://github.com/nodeca/js-yaml/compare/0.2.1...0.2.2
|
||||
[0.2.1]: https://github.com/nodeca/js-yaml/compare/0.2.0...0.2.1
|
||||
[0.2.0]: https://github.com/nodeca/js-yaml/releases/tag/0.2.0
|
21
bin/tags/node_modules/js-yaml/LICENSE
generated
vendored
21
bin/tags/node_modules/js-yaml/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2011-2015 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
299
bin/tags/node_modules/js-yaml/README.md
generated
vendored
299
bin/tags/node_modules/js-yaml/README.md
generated
vendored
@@ -1,299 +0,0 @@
|
||||
JS-YAML - YAML 1.2 parser / writer for JavaScript
|
||||
=================================================
|
||||
|
||||
[](https://travis-ci.org/nodeca/js-yaml)
|
||||
[](https://www.npmjs.org/package/js-yaml)
|
||||
|
||||
__[Online Demo](http://nodeca.github.com/js-yaml/)__
|
||||
|
||||
|
||||
This is an implementation of [YAML](http://yaml.org/), a human-friendly data
|
||||
serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was
|
||||
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### YAML module for node.js
|
||||
|
||||
```
|
||||
npm install js-yaml
|
||||
```
|
||||
|
||||
|
||||
### CLI executable
|
||||
|
||||
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
||||
|
||||
```
|
||||
npm install -g js-yaml
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
usage: js-yaml [-h] [-v] [-c] [-t] file
|
||||
|
||||
Positional arguments:
|
||||
file File with YAML document(s)
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-c, --compact Display errors in compact mode
|
||||
-t, --trace Show stack trace on error
|
||||
```
|
||||
|
||||
|
||||
### Bundled YAML library for browsers
|
||||
|
||||
``` html
|
||||
<!-- esprima required only for !!js/function -->
|
||||
<script src="esprima.js"></script>
|
||||
<script src="js-yaml.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var doc = jsyaml.load('greeting: hello\nname: world');
|
||||
</script>
|
||||
```
|
||||
|
||||
Browser support was done mostly for the online demo. If you find any errors - feel
|
||||
free to send pull requests with fixes. Also note, that IE and other old browsers
|
||||
needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate.
|
||||
|
||||
Notes:
|
||||
|
||||
1. We have no resources to support browserified version. Don't expect it to be
|
||||
well tested. Don't expect fast fixes if something goes wrong there.
|
||||
2. `!!js/function` in browser bundle will not work by default. If you really need
|
||||
it - load `esprima` parser first (via amd or directly).
|
||||
3. `!!bin` in browser will return `Array`, because browsers do not support
|
||||
node.js `Buffer` and adding Buffer shims is completely useless on practice.
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
Here we cover the most 'useful' methods. If you need advanced details (creating
|
||||
your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
|
||||
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more
|
||||
info.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
|
||||
// Get document, or throw exception on error
|
||||
try {
|
||||
const doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
||||
console.log(doc);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### safeLoad (string [ , options ])
|
||||
|
||||
**Recommended loading way.** Parses `string` as single YAML document. Returns either a
|
||||
plain object, a string or `undefined`, or throws `YAMLException` on error. By default, does
|
||||
not support regexps, functions and undefined. This method is safe for untrusted data.
|
||||
|
||||
options:
|
||||
|
||||
- `filename` _(default: null)_ - string to be used as a file path in
|
||||
error/warning messages.
|
||||
- `onWarning` _(default: null)_ - function to call on warning messages.
|
||||
Loader will call this function with an instance of `YAMLException` for each warning.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
|
||||
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
- `JSON_SCHEMA` - all JSON-supported types:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
- `DEFAULT_SAFE_SCHEMA` - all supported YAML types, without unsafe ones
|
||||
(`!!js/undefined`, `!!js/regexp` and `!!js/function`):
|
||||
http://yaml.org/type/
|
||||
- `DEFAULT_FULL_SCHEMA` - all supported YAML types.
|
||||
- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
||||
|
||||
NOTE: This function **does not** understand multi-document sources, it throws
|
||||
exception on those.
|
||||
|
||||
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
||||
So, the JSON schema is not as strictly defined in the YAML specification.
|
||||
It allows numbers in any notation, use `Null` and `NULL` as `null`, etc.
|
||||
The core schema also has no such restrictions. It allows binary notation for integers.
|
||||
|
||||
|
||||
### load (string [ , options ])
|
||||
|
||||
**Use with care with untrusted sources**. The same as `safeLoad()` but uses
|
||||
`DEFAULT_FULL_SCHEMA` by default - adds some JavaScript-specific types:
|
||||
`!!js/function`, `!!js/regexp` and `!!js/undefined`. For untrusted sources, you
|
||||
must additionally validate object structure to avoid injections:
|
||||
|
||||
``` javascript
|
||||
const untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
|
||||
|
||||
// I'm just converting that string, what could possibly go wrong?
|
||||
require('js-yaml').load(untrusted_code) + ''
|
||||
```
|
||||
|
||||
|
||||
### safeLoadAll (string [, iterator] [, options ])
|
||||
|
||||
Same as `safeLoad()`, but understands multi-document sources. Applies
|
||||
`iterator` to each document if specified, or returns array of documents.
|
||||
|
||||
``` javascript
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
yaml.safeLoadAll(data, function (doc) {
|
||||
console.log(doc);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### loadAll (string [, iterator] [ , options ])
|
||||
|
||||
Same as `safeLoadAll()` but uses `DEFAULT_FULL_SCHEMA` by default.
|
||||
|
||||
|
||||
### safeDump (object [ , options ])
|
||||
|
||||
Serializes `object` as a YAML document. Uses `DEFAULT_SAFE_SCHEMA`, so it will
|
||||
throw an exception if you try to dump regexps or functions. However, you can
|
||||
disable exceptions by setting the `skipInvalid` option to `true`.
|
||||
|
||||
options:
|
||||
|
||||
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
||||
- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements
|
||||
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
||||
in the safe schema) and skip pairs and single values with such types.
|
||||
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
|
||||
block to flow style for collections. -1 means block style everwhere
|
||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
||||
function, use the function to sort the keys.
|
||||
- `lineWidth` _(default: `80`)_ - set max line width.
|
||||
- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references
|
||||
- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older
|
||||
yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1
|
||||
- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded.
|
||||
|
||||
The following table show availlable styles (e.g. "canonical",
|
||||
"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml
|
||||
output is shown on the right side after `=>` (default setting) or `->`:
|
||||
|
||||
``` none
|
||||
!!null
|
||||
"canonical" -> "~"
|
||||
"lowercase" => "null"
|
||||
"uppercase" -> "NULL"
|
||||
"camelcase" -> "Null"
|
||||
|
||||
!!int
|
||||
"binary" -> "0b1", "0b101010", "0b1110001111010"
|
||||
"octal" -> "01", "052", "016172"
|
||||
"decimal" => "1", "42", "7290"
|
||||
"hexadecimal" -> "0x1", "0x2A", "0x1C7A"
|
||||
|
||||
!!bool
|
||||
"lowercase" => "true", "false"
|
||||
"uppercase" -> "TRUE", "FALSE"
|
||||
"camelcase" -> "True", "False"
|
||||
|
||||
!!float
|
||||
"lowercase" => ".nan", '.inf'
|
||||
"uppercase" -> ".NAN", '.INF'
|
||||
"camelcase" -> ".NaN", '.Inf'
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
``` javascript
|
||||
safeDump (object, {
|
||||
'styles': {
|
||||
'!!null': 'canonical' // dump null as ~
|
||||
},
|
||||
'sortKeys': true // sort object keys
|
||||
});
|
||||
```
|
||||
|
||||
### dump (object [ , options ])
|
||||
|
||||
Same as `safeDump()` but without limits (uses `DEFAULT_FULL_SCHEMA` by default).
|
||||
|
||||
|
||||
Supported YAML types
|
||||
--------------------
|
||||
|
||||
The list of standard YAML tags and corresponding JavaScipt types. See also
|
||||
[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and
|
||||
[YAML types repository](http://yaml.org/type/).
|
||||
|
||||
```
|
||||
!!null '' # null
|
||||
!!bool 'yes' # bool
|
||||
!!int '3...' # number
|
||||
!!float '3.14...' # number
|
||||
!!binary '...base64...' # buffer
|
||||
!!timestamp 'YYYY-...' # date
|
||||
!!omap [ ... ] # array of key-value pairs
|
||||
!!pairs [ ... ] # array or array pairs
|
||||
!!set { ... } # array of objects with given keys and null values
|
||||
!!str '...' # string
|
||||
!!seq [ ... ] # array
|
||||
!!map { ... } # object
|
||||
```
|
||||
|
||||
**JavaScript-specific tags**
|
||||
|
||||
```
|
||||
!!js/regexp /pattern/gim # RegExp
|
||||
!!js/undefined '' # Undefined
|
||||
!!js/function 'function () {...}' # Function
|
||||
```
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects
|
||||
or arrays as keys, and stringifies (by calling `toString()` method) them at the
|
||||
moment of adding them.
|
||||
|
||||
``` yaml
|
||||
---
|
||||
? [ foo, bar ]
|
||||
: - baz
|
||||
? { foo: bar }
|
||||
: - baz
|
||||
- baz
|
||||
```
|
||||
|
||||
``` javascript
|
||||
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
||||
```
|
||||
|
||||
Also, reading of properties on implicit block mapping keys is not supported yet.
|
||||
So, the following YAML document cannot be loaded.
|
||||
|
||||
``` yaml
|
||||
&anchor foo:
|
||||
foo: bar
|
||||
*anchor: duplicate key
|
||||
baz: bat
|
||||
*anchor: duplicate key
|
||||
```
|
||||
|
||||
|
||||
js-yaml for enterprise
|
||||
----------------------
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
132
bin/tags/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
132
bin/tags/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
@@ -1,132 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
|
||||
// stdlib
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
// 3rd-party
|
||||
var argparse = require('argparse');
|
||||
|
||||
|
||||
// internal
|
||||
var yaml = require('..');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var cli = new argparse.ArgumentParser({
|
||||
prog: 'js-yaml',
|
||||
version: require('../package.json').version,
|
||||
addHelp: true
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-c', '--compact' ], {
|
||||
help: 'Display errors in compact mode',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
// deprecated (not needed after we removed output colors)
|
||||
// option suppressed, but not completely removed for compatibility
|
||||
cli.addArgument([ '-j', '--to-json' ], {
|
||||
help: argparse.Const.SUPPRESS,
|
||||
dest: 'json',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-t', '--trace' ], {
|
||||
help: 'Show stack trace on error',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
cli.addArgument([ 'file' ], {
|
||||
help: 'File to read, utf-8 encoded without BOM',
|
||||
nargs: '?',
|
||||
defaultValue: '-'
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var options = cli.parseArgs();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readFile(filename, encoding, callback) {
|
||||
if (options.file === '-') {
|
||||
// read from stdin
|
||||
|
||||
var chunks = [];
|
||||
|
||||
process.stdin.on('data', function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
process.stdin.on('end', function () {
|
||||
return callback(null, Buffer.concat(chunks).toString(encoding));
|
||||
});
|
||||
} else {
|
||||
fs.readFile(filename, encoding, callback);
|
||||
}
|
||||
}
|
||||
|
||||
readFile(options.file, 'utf8', function (error, input) {
|
||||
var output, isYaml;
|
||||
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error('File not found: ' + options.file);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
console.error(
|
||||
options.trace && error.stack ||
|
||||
error.message ||
|
||||
String(error));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
output = JSON.parse(input);
|
||||
isYaml = false;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
try {
|
||||
output = [];
|
||||
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
||||
isYaml = true;
|
||||
|
||||
if (output.length === 0) output = null;
|
||||
else if (output.length === 1) output = output[0];
|
||||
|
||||
} catch (e) {
|
||||
if (options.trace && err.stack) console.error(e.stack);
|
||||
else console.error(e.toString(options.compact));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
options.trace && err.stack ||
|
||||
err.message ||
|
||||
String(err));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isYaml) console.log(JSON.stringify(output, null, ' '));
|
||||
else console.log(yaml.dump(output));
|
||||
});
|
3989
bin/tags/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
3989
bin/tags/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user