Slight improvements/fixes

pull/208/head
Kelvin Schoofs 4 years ago
parent b04e78886d
commit bbba8b7280

@ -287,6 +287,7 @@ export function getConfig(name: string) {
function valueMatches(a: any, b: any): boolean { function valueMatches(a: any, b: any): boolean {
if (typeof a !== typeof b) return false; if (typeof a !== typeof b) return false;
if (typeof a !== 'object') return a === b; if (typeof a !== 'object') return a === b;
if (!a || !b) return a === b;
if (Array.isArray(a)) { if (Array.isArray(a)) {
if (!Array.isArray(b)) return false; if (!Array.isArray(b)) return false;
if (a.length !== b.length) return false; if (a.length !== b.length) return false;

@ -56,19 +56,19 @@ export function activate(context: vscode.ExtensionContext) {
subscribe(vscode.window.createTreeView('sshfs-configs', { treeDataProvider: manager, showCollapseAll: true })); subscribe(vscode.window.createTreeView('sshfs-configs', { treeDataProvider: manager, showCollapseAll: true }));
subscribe(vscode.tasks.registerTaskProvider('ssh-shell', manager)); subscribe(vscode.tasks.registerTaskProvider('ssh-shell', manager));
async function pickAndClick(func: (name: string) => void, name?: string, activeOrNot?: boolean) { async function pickAndClick(func: (name: string | FileSystemConfig) => void, name?: string | FileSystemConfig, activeOrNot?: boolean) {
name = name || await pickConfig(manager, activeOrNot); name = name || await pickConfig(manager, activeOrNot);
if (name) func.call(manager, name); if (name) func.call(manager, name);
} }
registerCommand('sshfs.new', async () => manager.openSettings({ type: 'newconfig' })); registerCommand('sshfs.new', () => manager.openSettings({ type: 'newconfig' }));
registerCommand('sshfs.settings', () => manager.openSettings()); registerCommand('sshfs.settings', () => manager.openSettings());
registerCommand('sshfs.connect', (name?: string) => pickAndClick(manager.commandConnect, name, false)); registerCommand('sshfs.connect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandConnect, name, false));
registerCommand('sshfs.disconnect', (name?: string) => pickAndClick(manager.commandDisconnect, name, true)); registerCommand('sshfs.disconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandDisconnect, name, true));
registerCommand('sshfs.reconnect', (name?: string) => pickAndClick(manager.commandReconnect, name, true)); registerCommand('sshfs.reconnect', (name?: string | FileSystemConfig) => pickAndClick(manager.commandReconnect, name, true));
registerCommand('sshfs.terminal', (name?: string) => pickAndClick(manager.commandTerminal, name)); registerCommand('sshfs.terminal', (name?: string | FileSystemConfig) => pickAndClick(manager.commandTerminal, name));
registerCommand('sshfs.configure', (name?: string) => pickAndClick(manager.commandConfigure, name)); registerCommand('sshfs.configure', (name?: string | FileSystemConfig) => pickAndClick(manager.commandConfigure, name));
registerCommand('sshfs.reload', loadConfigs); registerCommand('sshfs.reload', loadConfigs);
} }

@ -100,12 +100,17 @@ class Logger {
} }
} }
export function censorConfig(config: FileSystemConfig): FileSystemConfig { export interface CensoredFileSystemConfig extends Omit<FileSystemConfig, 'sock'> {
sock?: string;
}
export function censorConfig(config: FileSystemConfig): CensoredFileSystemConfig {
return { return {
...config, ...config,
password: typeof config.password === 'string' ? '<censored>' : config.password, password: typeof config.password === 'string' ? '<censored>' : config.password,
passphrase: typeof config.passphrase === 'string' ? '<censored>' : config.passphrase, passphrase: typeof config.passphrase === 'string' ? '<censored>' : config.passphrase,
privateKey: config.privateKey instanceof Buffer ? `Buffer(${config.privateKey.length})` : config.privateKey, privateKey: config.privateKey instanceof Buffer ? `Buffer(${config.privateKey.length})` : config.privateKey,
sock: config.sock ? '<socket>' : config.sock,
}; };
} }

Loading…
Cancel
Save