Skip to content

Commit

Permalink
Add skipFailures option (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
molynerd authored Sep 12, 2024
1 parent 7eca1c3 commit 4023fb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface Options {
env?: Record<string, string>
timeout?: number
maxBuffer?: number
skipFailures?: boolean
}

// Known /vsistdout/ support.
Expand All @@ -47,6 +48,7 @@ class Ogr2ogr implements PromiseLike<Result> {
private customEnv?: Record<string, string>
private timeout: number
private maxBuffer: number
private skipFailures: boolean

constructor(input: Input, opts: Options = {}) {
this.inputPath = vsiStdIn
Expand All @@ -57,6 +59,7 @@ class Ogr2ogr implements PromiseLike<Result> {
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
Expand Down Expand Up @@ -146,13 +149,9 @@ class Ogr2ogr implements PromiseLike<Result> {

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

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 4023fb1

Please sign in to comment.