Skip to content

Commit

Permalink
ci: improve copyright script
Browse files Browse the repository at this point in the history
Ref: #11
  • Loading branch information
Tomas2D committed Aug 30, 2024
1 parent cd33204 commit fe68867
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

# Path to the package.json file
Expand All @@ -27,8 +28,24 @@ fi
AUTHOR=$(jq -r '.author' "$PACKAGE_JSON_PATH")

# Check if the author property is not null or empty
if [[ ! -n "$AUTHOR" ]]; then
if [[ -z "$AUTHOR" ]]; then
echo "Error: author property not found in package.json"
exit 1
fi

# Check if 'nwa' command is not available and 'go' is available, then install 'nwa'
if ! command -v nwa &> /dev/null && command -v go &> /dev/null; then
echo "Installing 'nwa' via 'go' (https://github.com/B1NARY-GR0UP/nwa)"
go install github.com/B1NARY-GR0UP/nwa@latest
# Ensure the GOPATH is added to the PATH environment variable
export PATH=$PATH:$(go env GOPATH)/bin
fi

nwa add -l apache -c "$AUTHOR" src dist tests
if command -v nwa &> /dev/null; then
nwa add -l apache -c "$AUTHOR" src dist tests scripts
elif command -v docker &> /dev/null; then
docker run -it -v "${PWD}:/src" ghcr.io/b1nary-gr0up/nwa:main add -l apache -c "$AUTHOR" src dist tests scripts
else
echo "Error: 'nwa' is not available. Either install it manually or install go/docker."
exit 1
fi

0 comments on commit fe68867

Please sign in to comment.