From b4df398c174292ba52629714f2c962e2e3397783 Mon Sep 17 00:00:00 2001 From: Nick Molyneux Date: Fri, 6 Sep 2024 16:57:24 -0700 Subject: [PATCH 1/2] adds skipFailures option --- index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index f5db4f5..9221911 100644 --- a/index.ts +++ b/index.ts @@ -26,6 +26,7 @@ interface Options { env?: Record timeout?: number maxBuffer?: number + skipFailures?: boolean } // Known /vsistdout/ support. @@ -47,6 +48,7 @@ class Ogr2ogr implements PromiseLike { private customEnv?: Record private timeout: number private maxBuffer: number + private skipFailures: boolean constructor(input: Input, opts: Options = {}) { this.inputPath = vsiStdIn @@ -57,6 +59,7 @@ class Ogr2ogr implements PromiseLike { this.customEnv = opts.env this.timeout = opts.timeout ?? 0 this.maxBuffer = opts.maxBuffer ?? 1024 * 1024 * 50 + this.skipFailures = opts.skipFailures ?? true let {path, ext} = this.newOutputPath(this.outputFormat) this.outputPath = path @@ -146,13 +149,9 @@ class Ogr2ogr implements PromiseLike { private async run() { let command = this.customCommand ?? "ogr2ogr" - let args = [ - "-f", - this.outputFormat, - "-skipfailures", - this.customDestination || this.outputPath, - this.inputPath, - ] + let args = ["-f", this.outputFormat] + if (this.skipFailures) args.push("-skipfailures") + args.push(this.customDestination || this.outputPath, this.inputPath) if (this.customOptions) args.push(...this.customOptions) let env = this.customEnv ? {...process.env, ...this.customEnv} : undefined From 846730fa76169720d888c3afb247506a20cd21d4 Mon Sep 17 00:00:00 2001 From: Nick Molyneux Date: Fri, 6 Sep 2024 17:04:05 -0700 Subject: [PATCH 2/2] update readme --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index edeed48..af9e7f1 100644 --- a/readme.md +++ b/readme.md @@ -69,6 +69,7 @@ The following **`options`** are available (none required): - `format` - Output format (default: `GeoJSON`) - `timeout` - Timeout, in milliseconds, before command forcibly terminated (default: `0`) - `maxBuffer` - Max output size in bytes for stdout/stderr (default: `1024 * 1024 * 50`) +- `skipFailures` - the `-skipfailures` switch is not included when false (default: true). - `options` - Custom [ogr2ogr arguments][4] and [driver options][5] (e.g. `['--config', 'SHAPE_RESTORE_SHX', 'TRUE']`) - `env` - Custom environmental variables (e.g. `{ATTRIBUTES_SKIP: 'YES'}`) - `destination` - Select another output than the **output** object (e.g. useful for writing to databases).