Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const update = (items) => {
const newConfig = sshConfig.parse('')
// Convert items to the config format and append to the new config.
items.forEach((item) => {
const convertedItem = convertToConfigFormat(item)
newConfig.append(convertedItem)
})
const newConfigString = sshConfig.stringify(newConfig);
const unmanagedConfig = readUnmanagedLocalConfig()
return unmanagedConfig
.trim()
.concat("\n", settings.startTag)
.concat("\n", newConfigString)
.concat("\n", settings.endTag)
}
it('should stringify with config3 file', async () => {
const config3 = await readFile(path.resolve(__dirname, 'fixtures/ssh-config/config3'), { encoding: 'utf8' });
const conf = SSHConfig.parse(config3);
ensureHostAndKeyPath(conf, { host: 'bar' }, '/id_rsa');
expect(SSHConfig.stringify(conf)).toEqual(config3);
});
async applyConfig(text: string, keyPath: string): Promise {
const c = await this.config.load();
const conf = SSHConfig.parse(text);
const host = c.git.host;
const section = this.ensureSection(conf, host, Boolean(text));
this.ensureSectionLine(section, 'IdentityFile', keyPath);
if (typeof c.git.port === 'number') {
this.ensureSectionLine(section, 'Port', String(c.git.port));
}
return SSHConfig.stringify(conf);
}