Skip to content

Commit 9a501fe

Browse files
committed
added publishing script
1 parent 79f07f5 commit 9a501fe

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

publish.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Step 1: Run Vitest for unit testing in "run" mode to avoid waiting for changes
4+
echo "Running unit tests with Vitest..."
5+
npx vitest run
6+
7+
# Check if the tests were successful
8+
if [ $? -ne 0 ]; then
9+
echo "Tests failed. Aborting publish."
10+
exit 1
11+
fi
12+
13+
echo "Tests passed. Proceeding with build and publish..."
14+
15+
# Step 2: Remove the dist folder
16+
echo "Removing dist folder..."
17+
rm -rf dist
18+
19+
# Step 3: Build the library
20+
echo "Building the library..."
21+
npm run build
22+
23+
# Check if the build was successful
24+
if [ $? -ne 0 ]; then
25+
echo "Build failed. Aborting publish."
26+
exit 1
27+
fi
28+
29+
echo "Build successful."
30+
31+
# Step 4: Publish the package
32+
echo "Publishing the package..."
33+
npm publish
34+
35+
# Check if the publish was successful
36+
if [ $? -ne 0 ]; then
37+
echo "Publish failed."
38+
exit 1
39+
fi
40+
41+
echo "Package published successfully!"

0 commit comments

Comments
 (0)