Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!Array.isArray(files)) {
throw new TypeError(`Expected an \`Array\`, got ${typeof files}`);
}
const editor = options.editor ? envEditor.getEditor(options.editor) : envEditor.defaultEditor();
const editorArguments = [];
if (editor.id === 'vscode') {
editorArguments.push('--goto');
}
for (const file of files) {
const parsed = lineColumnPath.parse(file);
if (['sublime', 'atom', 'vscode'].includes(editor.id)) {
editorArguments.push(lineColumnPath.stringify(parsed));
continue;
}
if (['webstorm', 'intellij'].includes(editor.id)) {
editorArguments.push(lineColumnPath.stringify(parsed, {column: false}));
continue;
}
if (editor.id === 'textmate') {
editorArguments.push('--line', lineColumnPath.stringify(parsed, {
file: false
}), parsed.file);
continue;
}
if (['vim', 'neovim'].includes(editor.id)) {
for (const file of files) {
const parsed = lineColumnPath.parse(file);
if (['sublime', 'atom', 'vscode'].includes(editor.id)) {
editorArguments.push(lineColumnPath.stringify(parsed));
continue;
}
if (['webstorm', 'intellij'].includes(editor.id)) {
editorArguments.push(lineColumnPath.stringify(parsed, {column: false}));
continue;
}
if (editor.id === 'textmate') {
editorArguments.push('--line', lineColumnPath.stringify(parsed, {
file: false
}), parsed.file);
continue;
}
if (['vim', 'neovim'].includes(editor.id)) {
editorArguments.push(`+call cursor(${parsed.line}, ${parsed.column})`, parsed.file);
continue;
}
editorArguments.push(parsed.file);
}
return {
binary: editor.binary,
arguments: editorArguments,