From the course: Learning Static Site Building with Hugo
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Connect to the server
From the course: Learning Static Site Building with Hugo
Connect to the server
- [Instructor] Let's create the deploy dot js script. I'll do new file call it, "deploy dot js" And we'll start writing the code that we need. I'll start by doing const SftpClient equals require ssh to SftpClient, which is one of the packages we grabbed via NPM. I'll also do next sftp equals new SftpClient. I'm going to declare a variable called, "items to upload". We'll come back to this in a sec, but first I want to have the sftp client connect to the server. I'll do sftp dot connect and passes some connection information. You'll specify a host and I'm going to not hard code the host, but I'm going to do process dot env dot ftp underscore deploy underscore host. That'll pull a value from environment variables and I'll show you how to hook that up a little bit later. I'm going to do the same thing for port. Ftp deploy port and for username and password as well. Password comes from process dot env like the other ones. Ftp underscore deploy underscore password. Storing connection…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.