1.8 KiB
| layout | title | description | permalink | redirect_from |
|---|---|---|---|---|
| docs | CLI | How to use the CLI tools. | /docs/usage/cli/ | /usage.html |
6to5 comes with a built-in CLI which can be used to compile files from the command line.
Install
Using npm you can install 6to5 globally, making it available from the command line.
$ npm install --global 6to5
6to5
Compile Files
Compile the file script.js and output to stdout.
$ 6to5 script.js
# output...
If you would like to output to a file you may use --out-file or -o.
$ 6to5 script.js --out-file script-compiled.js
Compile with Source Maps
If you would then like to add a source map file you can use
--source-maps or -s. Learn more about source maps.
$ 6to5 script.js --out-file script-compiled.js --source-maps
If you would rather have inline source maps, you may use
--source-maps-inline or -t.
$ 6to5 script.js --out-file script-compiled.js --source-maps-inline
Compile Directories
Compile the entire src directory and output it to the lib directory.
$ 6to5 src --out-dir lib
Compile the entire src directory and output it to the one concatenated file.
$ 6to5 src --out-file script-compiled.js
Piping Files
Pipe a file in via stdin and output it to script-compiled.js
$ 6to5 --out-file script-compiled.js < script.js
6to5-node
6to5 comes with a second CLI which works exactly the same as Node.js's CLI, only it will compile ES6 code before running it.
Launch a REPL (Read-Eval-Print-Loop).
$ 6to5-node
Evaluate code.
$ 6to5-node -e "class Test { }"
Compile and run test.js.
$ 6to5-node test