## babel-cli 常用命令
仍然使用上文中創建的 `src/main.js`進行測試
```js
let a = 0
```
### 控制臺輸出
```bash
$ babel src/main.js
"use strict";
var a = 0;
```
### 輸出到文件
如果想輸出編譯結果到單個文件,你可以使用 `--out-file` 或 `-o`
```bash
$ babel src/main.js --out-file output/main.js
```
### 監測文件改變
想要在每一次修改文件后編譯文件,請使用 `--watch` 或 `-w` 選項
```bash
$ babel src/main.js --watch --out-file output/main.js
```
## 使用 Source Maps 編譯
如果你想添加一個 **source map 文件** 你可以用 `--source-maps` 或者 `-s`。[了解更多關于 source maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)
```bash
$ babel src/main.js --out-file output/main.js --source-maps
```
如果你想使用 內聯的 source maps,你可以使用 `--source-maps inline`。
```bash
$ babel src/main.js --out-file output/main.js --source-maps inline
```
## 編譯目錄
編譯整個 `src` 目錄并將其輸出到 `lib` 目錄。你可以使用 `--out-dir` 或 `-d`。這不會覆蓋 `lib` 中的任何其他文件或目錄。
```bash
$ babel src --out-dir output
```
編譯整個 src 目錄并將其輸出到單個文件中。
```bash
$ babel src --out-file main.js
```
使用 `--ignore` 忽略指定的文件。
```
babel src --out-dir output --ignore spec.js,test.js
```
使用 `--copy-files`