1
1
#! /bin/bash
2
2
3
+ # Exit immediately if a command exits with a non-zero status.
4
+ set -ex
5
+
3
6
# Define the source directory for the resources
4
7
SOURCE_DIR=" resources"
5
8
@@ -9,23 +12,34 @@ DEST_DIR="vscode"
9
12
# Define paths for each file relative to the base directories
10
13
# Format: "source_file_path:destination_file_path"
11
14
FILES_TO_COPY=(
12
- " favicon.ico:src/sagemaker-code-editor/vscode/ resources/server/favicon.ico"
13
- " code-icon.svg:src/sagemaker-code-editor/vscode/src/ vs/workbench/browser/media/code-icon.svg"
14
- " letterpress-dark.svg:src/sagemaker-code-editor/vscode/src/ vs/workbench/browser/parts/editor/media/letterpress-dark.svg"
15
- " letterpress-hcDark.svg:src/sagemaker-code-editor/vscode/src/ vs/workbench/browser/parts/editor/media/letterpress-hcDark.svg"
16
- " letterpress-hcLight.svg:src/sagemaker-code-editor/vscode/src/ vs/workbench/browser/parts/editor/media/letterpress-hcLight.svg"
17
- " letterpress-light.svg:src/sagemaker-code-editor/vscode/src/ vs/workbench/browser/parts/editor/media/letterpress-light.svg"
15
+ " favicon.ico:resources/server/favicon.ico"
16
+ " code-icon.svg:src/vs/workbench/browser/media/code-icon.svg"
17
+ " letterpress-dark.svg:src/vs/workbench/browser/parts/editor/media/letterpress-dark.svg"
18
+ " letterpress-hcDark.svg:src/vs/workbench/browser/parts/editor/media/letterpress-hcDark.svg"
19
+ " letterpress-hcLight.svg:src/vs/workbench/browser/parts/editor/media/letterpress-hcLight.svg"
20
+ " letterpress-light.svg:src/vs/workbench/browser/parts/editor/media/letterpress-light.svg"
18
21
)
19
22
20
- # Loop through the file paths and copy each one to its new location
23
+ # Loop through the file paths, check if file exists, and copy each one to its new location
21
24
for FILE_PATH in " ${FILES_TO_COPY[@]} " ; do
22
25
IFS=" :" read -r SRC_FILE DEST_FILE <<< " $FILE_PATH"
23
26
24
27
# Construct full source and destination paths
25
28
FULL_SRC_PATH=" $SOURCE_DIR /$SRC_FILE "
26
29
FULL_DEST_PATH=" $DEST_DIR /$DEST_FILE "
27
30
31
+ # Check if the source file exists
32
+ if [ ! -f " $FULL_SRC_PATH " ]; then
33
+ echo " Error: Source file $FULL_SRC_PATH does not exist." >&2
34
+ exit 1
35
+ fi
36
+
37
+ # Check if the destination file exists. If so, delete it before copying.
38
+ if [ -f " $FULL_DEST_PATH " ]; then
39
+ rm " $FULL_DEST_PATH "
40
+ echo " Existing file $FULL_DEST_PATH deleted."
41
+ fi
42
+
28
43
# Copy file from source to destination
29
- cp " $FULL_SRC_PATH " " $FULL_DEST_PATH "
30
- echo " Copied $FULL_SRC_PATH to $FULL_DEST_PATH "
44
+ cp -v " $FULL_SRC_PATH " " $FULL_DEST_PATH "
31
45
done
0 commit comments