mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-22 11:33:09 +00:00
34 lines
1,013 B
Bash
Executable file
34 lines
1,013 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# Returns 1 if program is installed and 0 otherwise
|
|
function program_installed {
|
|
local return_=1
|
|
|
|
type $1 >/dev/null 2>&1 || { local return_=0; }
|
|
|
|
echo "$return_"
|
|
}
|
|
|
|
function main() {
|
|
# Ensure required programs are installed
|
|
if [ $(program_installed git) == 0 ]; then
|
|
echo "Please install Git."
|
|
elif [ $(program_installed ghp-import) == 0 ]; then
|
|
echo "Please install ghp-import: pip install ghp-import."
|
|
elif [ $(program_installed mdbook) == 0 ]; then
|
|
echo "Please install mdbook: cargo install mdbook."
|
|
else
|
|
echo "Copying CONTRIBUTING.md to src/pages/contributing.md"
|
|
cp CONTRIBUTING.md src/pages/contributing.md
|
|
echo "Building site to book/"
|
|
mdbook build
|
|
echo "Copying assets/* to book/"
|
|
cp -r assets/ book/
|
|
echo "Committing book directory to gh-pages branch"
|
|
ghp-import -p book
|
|
# echo ""
|
|
# echo "To push changes to site, run ghp-import -p book"
|
|
fi
|
|
}
|
|
|
|
main
|