LEARNING JAVASCRIPT - Trang 42

Bash translates backslashes to forward slashes. Bash also uses the tilde (

~

) as a short‐

cut for your home directory (where you should normally be storing your files).
The basics you’ll need are the ability to change the current directory (

cd

), and make

new directories (

mkdir

). For example, to go to your home directory, type:

$ cd ~

The command

pwd

(print working directory) tells you what directory you’re currently

in:

$ pwd

To create a subdirectory called test, type:

$ mkdir test

To change to this newly created directory, type:

$ cd test

Two periods (

..

) are a shortcut for “parent directory.” So to go “up” a directory (if

you’ve been following along, this will take you back to your home directory), type:

$ cd ..

There’s a lot more to learn about the terminal, but these basic commands are all you

need to get through the material in this chapter. If you want to learn more, I recom‐

mend the

Console Foundations course on Treehouse

.

Your Project Root

You’ll want to create a directory for each project. We’ll call this directory the project

root. For example, if you’re following along with the examples in this book, you could

create an lj directory, which would be your project root. In all the command-line

examples in this book, we’ll assume that you’re in the project root. If you try an exam‐

ple and it doesn’t work, the first thing to verify is that you’re in the project root. Any

files we create will be relative to the project root. For example, if your project root

is /home/joe/work/lj, and we ask you to create a file public/js/test.js, the full path to

that file should be /home/joe/work/lj/public/js/test.js.

Version Control: Git

We won’t discuss version control in detail in this book, but if you’re not using it, you

should be. If you’re not familiar with Git, I encourage you to use this book as an

opportunity to practice.
First, from your project root, initialize a repository:

$ git init

18 | Chapter 2: JavaScript Development Tools

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.