Skip to content

Commit

Permalink
Allow raw geostyler output
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Nov 28, 2021
1 parent b2e1651 commit c6185a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async function collectPaths(basePath: string, isFile: boolean): Promise<string[]

async function writeFile(
sourceFile: string, sourceParser: StyleParser,
targetFile: string, targetParser: StyleParser,
targetFile: string, targetParser: StyleParser | undefined,
oraIndicator: Ora
) {
const inputFileData = await promises.readFile(sourceFile, 'utf-8');
Expand All @@ -146,7 +146,7 @@ async function writeFile(
indicator.text = `Reading from ${sourceFile}`;
const geostylerStyle = await sourceParser.readStyle(inputFileData);
indicator.text = `Writing to ${targetFile}`;
const targetStyle = await targetParser.writeStyle(geostylerStyle);
const targetStyle = targetParser ? await targetParser.writeStyle(geostylerStyle) : JSON.stringify(geostylerStyle);
if (targetFile) {
await promises.writeFile(targetFile, targetStyle, 'utf-8');
indicator.succeed(`File "${sourceFile}" translated successfully. Output written to ${targetFile}`);
Expand Down Expand Up @@ -229,8 +229,7 @@ async function main() {
return;
}
if (!targetParser) {
indicator.fail('No targetparser was specified.');
return;
indicator.info('No targetparser was specified. Output will be a Geostyler object.');
}

// Get source(s) path(s).
Expand Down
4 changes: 3 additions & 1 deletion src/logHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export const logHelp = () :void => {
Options:
-h / --help : Display this help.
-o / --output : Output filename or directory. Required. [string]
-o / --output : Output filename or directory. Mandatory if the target
is a directory. If not provided for a single file then output
will be written to stdout. [string]
-s / --source : SourceParser, either "mapbox", "mapfile" or "map", "sld",
"qgis" or "qml". If not given, it will be guessed from the
extension of the output file. Mandatory if the the target
Expand Down

0 comments on commit c6185a2

Please sign in to comment.