/ scripts / nimble.sh
nimble.sh
 1  #!/usr/bin/env bash
 2  
 3  # Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
 4  # either of:
 5  # - Apache License, version 2.0
 6  # - MIT license
 7  # at your option. This file may not be copied, modified, or distributed except
 8  # according to those terms.
 9  
10  ######################################################
11  # run *.nimble tasks using "nim" instead of "nimble" #
12  ######################################################
13  
14  # exit on command error
15  set -e
16  
17  [ -z "$1" ] && { echo "usage: $0 task_name"; exit 1; }
18  
19  F=""
20  for F in *.nimble; do
21  	# get the first one
22  	break
23  done
24  [ -z "$F" ] && { echo "No *.nimble file found."; exit 1; }
25  
26  # "nim" seems to only run custom NimScript files if they have a "nims" extension
27  NIMS="${F%.nimble}.nims"
28  # delete the temporary symlink on script exit
29  cleanup() {
30  	rm -rf "$NIMS"
31  }
32  [ -e "$NIMS" ] || { ln -s "$F" "$NIMS"; trap cleanup EXIT; }
33  
34  # can't have an "exec" here or the EXIT pseudo-signal won't be triggered
35  $(dirname $0)/env.sh nim "$@" "$NIMS"
36