-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from headwaymaps/mkirk/fixup-pelias-config
fixup pelias config
- Loading branch information
Showing
6 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 25 additions & 2 deletions
27
services/pelias/generate_config/src/scripts/generatePeliasConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
import { generate, parseArgs } from "../index"; | ||
import { generate } from "../index"; | ||
import { readFileSync } from "fs"; | ||
|
||
const config = generate(readFileSync(0, "utf-8"), parseArgs()); | ||
export function parseArgs(args: string[]): [string, string, string[]] { | ||
const USAGE = `ARGS: \n <inputPath> <area> [<countries ...>]`; | ||
|
||
const inputPath = args.shift(); | ||
if (!inputPath) { | ||
console.error(USAGE); | ||
throw Error("Missing `inputPath` arg"); | ||
} | ||
|
||
const area = args.shift(); | ||
if (!area) { | ||
console.error(USAGE); | ||
throw Error("Missing `area` arg"); | ||
} | ||
|
||
const countries = args; | ||
return [inputPath, area, countries]; | ||
} | ||
|
||
// Get just the args from `node $cmd [args...]` | ||
const args = process.argv.slice(2); | ||
const [inputPath, area, countries] = parseArgs(args); | ||
const input = readFileSync(inputPath, "utf-8"); | ||
const config = generate(input, area, countries); | ||
console.log(JSON.stringify(config, undefined, 2)); |