From aa3fbe2bf6e39732135358657aabe0e37223a445 Mon Sep 17 00:00:00 2001 From: 4lessandrodev Date: Tue, 1 Mar 2022 11:59:35 -0300 Subject: [PATCH] chore(env): added racking to check environment --- .eslintignore | 1 + .eslintrc.js | 2 +- package.json | 4 ++-- scripts/post-install.sh | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 .eslintignore create mode 100755 scripts/post-install.sh diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..3232423 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +*.types.ts diff --git a/.eslintrc.js b/.eslintrc.js index 61ce2c7..346bdc0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,4 +30,4 @@ module.exports = { 'no-tabs': 0, 'space-before-function-paren': ['error', 'always'], }, -}; +}; \ No newline at end of file diff --git a/package.json b/package.json index 669595e..3df85c7 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "license": "MIT", "scripts": { "prestart:dev": "lsof -i:3000 | awk '/node/{print $2}' | awk 'NR == 1' | xargs -r kill -9 ", - "postinstall": "npm run generate:gql", + "postinstall": "./scripts/post-install.sh", "prebuild": "rimraf dist", "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", @@ -25,7 +25,6 @@ }, "dependencies": { "@apollo/gateway": "^0.34.0", - "@graphql-codegen/typescript-resolvers": "^2.5.2", "@nestjs/common": "^8.1.2", "@nestjs/core": "^8.1.2", "@nestjs/graphql": "^8.0.2", @@ -57,6 +56,7 @@ "devDependencies": { "@graphql-codegen/cli": "^2.6.2", "@graphql-codegen/typescript": "^2.4.5", + "@graphql-codegen/typescript-resolvers": "^2.5.2", "@microsoft/tsdoc": "0.13.2", "@nestjs/cli": "8.0.2", "@nestjs/schematics": "8.0.2", diff --git a/scripts/post-install.sh b/scripts/post-install.sh new file mode 100755 index 0000000..2ed1793 --- /dev/null +++ b/scripts/post-install.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# This file check environment and run a specific command for each one + +# Get node environment +NODE_ENV="$(printenv | awk '/^NODE_ENV/{print $1}')"; + + +if [[ "$NODE_ENV" == "NODE_ENV=production" ]]; then + + # Run production commands + echo "Production"; + +else + + # Run dev commands + npm run generate:gql + +fi;