Jelajahi Sumber

:wrench: Convert bash script to fish script

DricomDragon 1 tahun lalu
induk
melakukan
b6f9c6fe7e
2 mengubah file dengan 33 tambahan dan 25 penghapusan
  1. 33 0
      undeployed/scripts/deploy-to-ovh.fish
  2. 0 25
      undeployed/scripts/deploy-to-ovh.sh

+ 33 - 0
undeployed/scripts/deploy-to-ovh.fish

@@ -0,0 +1,33 @@
+#!/usr/bin/fish
+
+echo 'Deploy website through FTP'
+
+function require
+        set var $argv[1]
+        if not set -q $var
+                echo "Please provide a value for $var"
+                echo "Did you run the command source against your .env.local?"
+                exit
+        end
+end
+require FTP_HOST
+require FTP_USER
+require FTP_DEST
+require DIST_DIR
+
+set files (find $DIST_DIR -type f)
+echo 'Files to be sent :'
+echo "$files"
+
+echo "FTP to $FTP_HOST"
+read --prompt-str "[deploy] password for $FTP_USER: " --silent password
+echo
+
+# ftp operation
+set ftp_cmd "\
+user $FTP_USER $password
+nmap $DIST_DIR/\$1 $FTP_DEST/\$1
+mput $files
+bye
+"
+echo $ftp_cmd | ftp -pvin $FTP_HOST $FTP_PORT 

+ 0 - 25
undeployed/scripts/deploy-to-ovh.sh

@@ -1,25 +0,0 @@
-#!/bin/bash
-
-echo 'Deploy website through FTP'
-
-: "{FTP_HOST:?FTP_HOST not set or empty}"
-: "{FTP_USER:?FTP_USER not set or empty}"
-: "{FTP_PORT:=21}"
-: "{FTP_DEST:=www}"
-: "{DIST_DIR:=dist}"
-
-files=`find $DIST_DIR -type f`
-echo 'Files to be sent :'
-echo "$files"
-
-echo "FTP to $FTP_HOST"
-read -s -p "[deploy] password for $FTP_USER: " password
-echo
-
-# ftp operation
-ftp -pvin $FTP_HOST $FTP_PORT<<EOT
-user $FTP_USER $password
-nmap $DIST_DIR\$1 $FTP_DEST/\$1
-mput $files
-bye
-EOT