Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports #73: add port option to serve command #92

Merged
merged 2 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/source/usage/commandline_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ Realtime editor on browser
Options:
--provider [provider] your map service. e.g. `mapbox`, `geolonia`
--mapbox-access-token [mapboxAccessToken] Access Token for the Mapbox
--port [port] Specify custom port
-h, --help display help for command

Charites has two options for `serve` command.
Charites has three options for `serve` command.

- `--provider` - `mapbox`, `geolonia`, or `default`. When not specified, default or the value in the configuration file will be used.

- `mapbox` - The format linter runs against the Mapbox GL JS v2.x compatible specification.
- `geolonia` and `default` - the format linter runs against the MapLibre GL JS compatible specification.

- `--mapbox-access-token` - Set your access-token when styling for Mapbox.

- `--port` - Set http server's port number. When not specified, use 8080 port.
2 changes: 2 additions & 0 deletions src/cli/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ program
'--mapbox-access-token [mapboxAccessToken]',
'Access Token for the Mapbox',
)
.option('--port [port]', 'Specify custom port')
.action((source: string, serveOptions: serveOptions) => {
const options: serveOptions = program.opts()
options.provider = serveOptions.provider
options.mapboxAccessToken = serveOptions.mapboxAccessToken
options.port = serveOptions.port
if (!fs.existsSync(defaultSettings.configFile)) {
fs.writeFileSync(
defaultSettings.configFile,
Expand Down
6 changes: 5 additions & 1 deletion src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import { defaultValues } from '../lib/defaultValues'
export interface serveOptions {
provider?: string
mapboxAccessToken?: string
port?: string
}

export function serve(source: string, options: serveOptions) {
const port = process.env.PORT || 8080
let port = process.env.PORT || 8080
if (options.port) {
port = Number(options.port)
}
let sourcePath = path.resolve(process.cwd(), source)

let provider = defaultValues.provider
Expand Down