From 4023fb19b599f5b61e2f139f72bf1a387a1406d2 Mon Sep 17 00:00:00 2001 From: Nick Molyneux Date: Thu, 12 Sep 2024 14:58:53 -0700 Subject: [PATCH] Add skipFailures option (#109) https://github.com/wavded/ogr2ogr/issues/87 --- index.ts | 13 ++++++------- readme.md | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index 2f04464..318d1ac 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 diff --git a/readme.md b/readme.md index e7b867b..f276ac5 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).