Skip to content

Commit

Permalink
chore(scripts): move pre start script from package.json to a sh file
Browse files Browse the repository at this point in the history
  • Loading branch information
4lessandrodev committed Apr 3, 2022
1 parent 8fa1658 commit c828f2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"license": "MIT",
"scripts": {
"prestart:dev": "lsof -i:3000 | awk '/node/{print $2}' | awk 'NR == 1' | xargs -r kill -9 ",
"prestart:dev": "./scripts/pre-start-dev.sh",
"postinstall": "./scripts/post-install.sh",
"prebuild": "rimraf dist",
"build": "nest build",
Expand Down
10 changes: 9 additions & 1 deletion scripts/check-deps.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/bin/sh
#!/bin/bash

# read all dependencies name on package.json

DEPS="$(cat package.json | grep -A 100 "dependencies" | grep -B 100 "\}\," | \
awk "NR>1" | sed -e "s/},//" | tr -d '":.^0-9,')";

# loop on dependencies names and save each name on a file

for dep in "$(echo $DEPS)"; do
echo $dep | sed -e 's/ /\n/g' > deps;
done;

# read each name on saved file and check version on yarn.lock

while IFS= read -r line; do
yarn list --depth 0 | grep $line@
done < ./deps;

# delete file

rm -rf ./deps
10 changes: 9 additions & 1 deletion scripts/check-dev-deps.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#!/bin/sh
#!/bin/bash

# read all devDependencies name on package.json

DEV_DEPS="$(cat package.json | grep -A 100 "devDependencies" | grep -B 100 "\}\," | \
awk "NR>1" | sed -e "s/},//" | tr -d '":.^0-9,')";

# loop on dependencies names and save each name on a file

for dep in "$(echo $DEV_DEPS)"; do
echo $dep | sed -e 's/ /\n/g' > deps;
done;

# read each name on saved file and check version on yarn.lock

while IFS= read -r line; do
yarn list --depth 0 | grep $line@
done < ./deps;

# delete file

rm -rf ./deps
5 changes: 5 additions & 0 deletions scripts/pre-start-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# check if some node app is running on port 3000 and kill the process

lsof -i:3000 | awk '/node/{print $2}' | awk 'NR == 1' | xargs -r kill -9

0 comments on commit c828f2f

Please sign in to comment.