ssh-config
Advanced tools
Comparing version 4.1.5 to 4.1.6
21
index.js
@@ -82,3 +82,3 @@ 'use strict' | ||
/** | ||
* find section by Host or Match | ||
* find section by Host / Match or function | ||
*/ | ||
@@ -96,13 +96,18 @@ find(opts = {}) { | ||
/** | ||
* Remove section | ||
* Remove section by Host / Match or function | ||
*/ | ||
remove(opts = {}) { | ||
if (!(opts && ('Host' in opts || 'Match' in opts))) { | ||
throw new Error('Can only remove by Host or Match') | ||
} | ||
let index; | ||
const index = typeof opts === 'function' | ||
? super.findIndex(opts) | ||
: super.findIndex(line => compare(line, opts)) | ||
if (typeof opts === 'function') { | ||
index = super.findIndex(opts); | ||
} else if (!(opts && ('Host' in opts || 'Match' in opts))) { | ||
throw new Error('Can only remove by Host or Match'); | ||
} else { | ||
index = super.findIndex(line => compare(line, opts)); | ||
} | ||
if (index >= 0) return this.splice(index, 1) | ||
@@ -109,0 +114,0 @@ } |
{ | ||
"name": "ssh-config", | ||
"description": "SSH config parser and stringifier", | ||
"version": "4.1.5", | ||
"version": "4.1.6", | ||
"author": "Chen Yangjian (https://www.cyj.me)", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -111,3 +111,3 @@ # SSH Config Parser & Stringifier | ||
### `.remove` sections by Host or other criteria | ||
### `.remove` sections by Host / Match or function | ||
@@ -118,2 +118,4 @@ To remove sections, we can pass the section to `.remove(opts)`. | ||
config.remove({ Host: 'example1' }) | ||
// or the ES2015 Array.prototype.find | ||
config.remove(line => line.param == 'Host' && line.value == 'example1') | ||
``` | ||
@@ -120,0 +122,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20978
467
227