-
Notifications
You must be signed in to change notification settings - Fork 422
/
cli-api.md
63 lines (41 loc) · 1.66 KB
/
cli-api.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: Stencil Core CLI API
description: Stencil Core CLI API
url: /docs/cli-api
contributors:
- adamdbradley
---
# Stencil Core CLI API
The CLI API can be found at `@stencil/core/cli` and ran by `bin/stencil`.
## createNodeLogger()
```tsx
createNodeLogger(process: any): Logger
```
Creates a "logger", based off of NodeJS APIs, that will be used by the compiler and dev-server.
By default the CLI uses this method to create the NodeJS logger. The NodeJS "process"
object should be provided as the first argument.
## createNodeSystem()
```tsx
createNodeSystem(process: any): CompilerSystem
```
Creates the "system", based off of NodeJS APIs, used by the compiler. This includes any and
all file system reads and writes using NodeJS. The compiler itself is unaware of Node's
`fs` module. Other system APIs include any use of `crypto` to hash content. The NodeJS "process"
object should be provided as the first argument.
## parseFlags()
```tsx
parseFlags(args: string[]): ConfigFlags
```
Used by the CLI to parse command-line arguments into a typed `ConfigFlags` object.
This is an example of how it's used internally: `parseFlags(process.argv.slice(2))`.
## run()
```tsx
run(init: CliInitOptions): Promise<void>
```
Runs the CLI with the given options. This is used by Stencil's default `bin/stencil` file,
but can be used externally too.
## runTask()
```tsx
runTask(process: any, config: Config, task: TaskCommand, sys?: CompilerSystem): Promise<void>
```
Runs individual tasks giving a NodeJS `process`, Stencil `config`, and task command. You can optionally pass in the `sys` that's used by the compiler. See [createNodeSystem()](#createnodesystem) for more details.