Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssh-config

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-config - npm Package Compare versions

Comparing version 4.0.6 to 4.1.0

13

History.md

@@ -0,1 +1,14 @@

4.1.0 / 2021-10-20
==================
## What's Changed
* test: switching to github actions by @cyjake in https://github.com/cyjake/ssh-config/pull/44
* feat: add prepend function to prepend options onto config by @tanhakabir in https://github.com/cyjake/ssh-config/pull/45
* build: switch to codecov by @cyjake in https://github.com/cyjake/ssh-config/pull/46
## New Contributors
* @tanhakabir made her first contribution in https://github.com/cyjake/ssh-config/pull/45
**Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.0.6...v4.1.0
4.0.6 / 2021-05-11

@@ -2,0 +15,0 @@ ==================

@@ -10,2 +10,3 @@ 'use strict'

const RE_QUOTE_DIRECTIVE = /^(?:CertificateFile|IdentityFile|User)$/i
const RE_SINGLE_LINE_DIRECTIVE = /^(Include|IdentityFile)$/i

@@ -158,2 +159,80 @@ const DIRECTIVE = 1

/**
* Prepend new section to existing ssh config.
* @param {Object} opts
*/
prepend(opts, beforeFirstSection = false) {
let indent = ' '
outer:
for (const line of this) {
if (RE_SECTION_DIRECTIVE.test(line.param)) {
for (const subline of line.config) {
if (subline.before) {
indent = subline.before
break outer
}
}
}
}
let config = this
let i = 0
// insert above known sections
if (beforeFirstSection) {
while (i < this.length && !RE_SECTION_DIRECTIVE.test(this[i].param)) {
i += 1
}
if (i >= this.length) { // No sections in original config
return this.append(opts)
}
}
// Prepend new section above the first section
let sectionLineFound = false
let processedLines = 0
for (const param in opts) {
processedLines += 1
const line = {
type: DIRECTIVE,
param,
separator: ' ',
value: opts[param],
before: '',
after: '\n'
}
if (RE_SECTION_DIRECTIVE.test(param)) {
config.splice(i, 0, line)
config = line.config = new SSHConfig()
sectionLineFound = true
continue
}
// separate from previous sections with an extra newline
if (processedLines === Object.keys(opts).length) {
line.after += '\n'
}
if (!sectionLineFound) {
config.splice(i, 0, line)
i += 1
// Add an extra newline if a single line directive like Include
if (RE_SINGLE_LINE_DIRECTIVE.test(param)) {
line.after += '\n'
}
continue
}
line.before = indent
config.push(line)
}
return config
}
/**
* Stringify structured object into ssh config text

@@ -160,0 +239,0 @@ * @param {SSHConfig} config

6

package.json
{
"name": "ssh-config",
"description": "SSH config parser and stringifier",
"version": "4.0.6",
"version": "4.1.0",
"author": "Chen Yangjian (https://www.cyj.me)",

@@ -23,8 +23,8 @@ "repository": {

"test": "mocha --exit",
"coveralls": "nyc mocha --exit && nyc report --reporter=text-lcov | coveralls"
"test:coverage": "nyc mocha --exit && nyc report --reporter=lcov"
},
"engine": {
"node": ">= 6.0.0"
"node": ">= 10.0.0"
},
"license": "MIT"
}

@@ -6,3 +6,4 @@ # SSH Config Parser & Stringifier

[![Build Status](https://travis-ci.org/cyjake/ssh-config.svg)](https://travis-ci.org/cyjake/ssh-config)
[![Coverage Status](https://coveralls.io/repos/github/cyjake/ssh-config/badge.svg?branch=master)](https://coveralls.io/github/cyjake/ssh-config?branch=master)
[![Node CI](https://github.com/cyjake/ssh-config/actions/workflows/nodejs.yml/badge.svg)](https://github.com/cyjake/ssh-config/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/cyjake/ssh-config/branch/master/graph/badge.svg?token=RMyTgcL8Kg)](https://codecov.io/gh/cyjake/ssh-config)

@@ -9,0 +10,0 @@ ## Usage

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc