https://github.com/HazyResearch/deepdive
Revision 57fa6e3622728be85727b5aa99c0727889e6dc89 authored by Raphael Hoffmann on 30 December 2015, 01:40:52 UTC, committed by Raphael Hoffmann on 31 December 2015, 01:22:09 UTC
1 parent e86bd69
Raw File
Tip revision: 57fa6e3622728be85727b5aa99c0727889e6dc89 authored by Raphael Hoffmann on 30 December 2015, 01:40:52 UTC
Adds schema support
Tip revision: 57fa6e3
find-deepdive-app
#!/usr/bin/env bash
# find-deepdive-app -- Recognizes which DeepDive application current working directory belongs to
#
# Uses $DEEPDIVE_APP environment if available.
##
set -eu

# locate application root
at_deepdive_app_root() {
    # recognize an app directory as defined in ../doc/doc/advanced/deepdiveapp.md
    [[ ( -e app.ddlog || ( -e deepdive.conf && ( -e schema.sql || -e schema.json ) ) ) && -e db.url ]]
}

if [[ -d "${DEEPDIVE_APP:-}" ]]; then
    cd "$DEEPDIVE_APP"
    if at_deepdive_app_root; then
        echo "$DEEPDIVE_APP"
    else
        error "$DEEPDIVE_APP: \$DEEPDIVE_APP does not point to a DeepDive application: deepdive.conf, db.url, and schema.sql should be all present"
    fi
else
    PWD_orig=$PWD
    while ! at_deepdive_app_root && [[ $PWD != / ]]; do
        cd ..
    done

    if at_deepdive_app_root; then
        pwd
    else
        error "$PWD_orig: Not inside a DeepDive application: deepdive.conf, db.url, and schema.sql should be all present in a parent directory"
    fi
fi
back to top