-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·62 lines (44 loc) · 1.64 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Get the directory where this script is located
script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#run npm i if node_modules does not exist
if [ ! -d "$script_directory/node_modules" ]; then
npm i
fi
# Parent directory where your subdirectories are located
parent_directory="$script_directory/src-extensions"
# Directory where you want to copy the 'dist' folders
destination_directory="$script_directory/extensions"
# Loop through each subdirectory in the parent directory
for directory in $parent_directory/*; do
# Go to Directory
cd $directory
echo $directory;
#check if node_modules exists, if not run npm i
if [ ! -d "$directory/node_modules" ]; then
npm i
fi
# Build the extension
npm run build
# Get the name of the subdirectory
directory_name=${directory##*/}
# Target Directory name with directus-extension prefix
directory_name="directus-extension-$directory_name"
# Create the destination directory if it doesn't exist
mkdir -p $destination_directory/$directory_name
# Copy the 'dist' folder to the destination directory
cp -r $directory/dist $destination_directory/$directory_name
# copy package-json
cp $directory/package.json $destination_directory/$directory_name
done
#check if uploads folder exists if not create it
if [ ! -d "$script_directory/uploads" ]; then
mkdir -p $script_directory/uploads
fi
#check if .env file exists if not copy .env-sample to .env
if [ ! -f "$script_directory/.env" ]; then
cp $script_directory/.env-sample $script_directory/.env
fi
#cd to script_directory
cd $script_directory
echo "Build finished"