add logging

This commit is contained in:
Denis Lehmann 2021-03-11 13:03:41 +01:00
parent ee563bb987
commit 49973291c4
3 changed files with 53 additions and 7 deletions

View file

@ -10,14 +10,19 @@
** node_environment ** node_environment
1. Create a directory =.npm= 1. Create a directory =.npm/bin= if not existent
2. If the file =global_packages.txt= is present, install the packages via *npm* globally in the =.npm= directory 2. Add the =.npm/bin= directory to the ~$PATH~ variable
3. Run ~npm install~ if a file =package.json= is present 3. Upgrade npm to the latest version
4. Add the =.npm= directory to the ~$PATH~ variable 4. If the file =global_packages.txt= is present, install the packages via npm into the =.npm= directory
5. Run ~npm install~ if a file =package.json= is present
** python_environment ** python_environment
1. Create a new python virtualenv in the folder =.venv= 1. Create a new python virtualenv in the folder =.venv= if not existent
2. Source the virtual environment 2. Source the virtual environment
3. Upgrade pip to the latest version 3. Upgrade pip to the latest version
4. If present, install the packages from the file =requirements.txt= via pip 4. If present, install the packages from the file =requirements.txt= via pip
** rust_environment
1. Run ~cargo build~ if =Cargo.toml= is present

View file

@ -5,13 +5,35 @@ pkgs.mkShell {
nodejs nodejs
]; ];
shellHook = '' shellHook = ''
mkdir -p .npm function log_header {
echo -ne "==> \e[32m\e[1m$1\e[0m\n\n"
}
function log_subheader {
echo -ne "--> \e[33m\e[1m$1\e[0m\n\n"
}
function log {
echo -ne " $1\n"
}
echo ""
log_header "node_environment"
mkdir -p .npm/bin
export PATH=$PWD/.npm/bin:$PATH
log_subheader "upgrading npm"
npm install -g npm --prefix $PWD/.npm
echo ""
if [ -s global_packages.txt ]; then if [ -s global_packages.txt ]; then
log_subheader "found global_packages.txt, installing packages"
cat global_packages.txt | xargs npm install -g --prefix $PWD/.npm cat global_packages.txt | xargs npm install -g --prefix $PWD/.npm
echo ""
fi fi
if [ -s package.json ]; then if [ -s package.json ]; then
log_subheader "found package.json, running 'npm install'"
npm install npm install
echo ""
fi fi
export PATH=$PWD/.npm/bin:$PATH log_header "package versions"
log "node $(node --version)"
log "npm $(npm --version)"
''; '';
} }

View file

@ -6,13 +6,32 @@ pkgs.mkShell {
python3Packages.virtualenv python3Packages.virtualenv
]; ];
shellHook = '' shellHook = ''
function log_header {
echo -ne "==> \e[32m\e[1m$1\e[0m\n\n"
}
function log_subheader {
echo -ne "--> \e[33m\e[1m$1\e[0m\n\n"
}
function log {
echo -ne " $1\n"
}
echo ""
log_header "python_environment"
if [ ! -d .venv ]; then if [ ! -d .venv ]; then
python -m venv .venv python -m venv .venv
fi fi
source .venv/bin/activate source .venv/bin/activate
log_subheader "upgrading pip"
pip install --upgrade pip pip install --upgrade pip
echo ""
if [ -s requirements.txt ]; then if [ -s requirements.txt ]; then
log_subheader "found requirements.txt, installing packages"
pip install -r requirements.txt pip install -r requirements.txt
echo ""
fi fi
log_header "package versions"
log "$(python --version)"
log "$(pip --version)"
''; '';
} }