Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function openEditor(context, filePath) {
const continueQuestion = {
type: 'input',
name: 'pressKey',
message: 'Press enter to continue',
};
// Check if default editor is chosen in init step
const { defaultEditor } = getEnvInfo();
const editorSelected = defaultEditor || (await editorSelection());
if (editorSelected !== 'none') {
const editorArguments = [];
const editor = envEditor.getEditor(editorSelected);
if (!editor) {
console.error(
`Selected editor '${editorSelected}' was not found in your machine. Please open your favorite editor and modify the file if needed.`
);
}
const editorPath = editor.paths.find(p => fs.existsSync(p));
if (editorSelected === 'vscode') {
editorArguments.push('--goto');
}
editorArguments.push(filePath);
try {
if (!editor.isTerminalEditor) {
const make = (files, options = {}) => {
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}));
export const getUserEditors = (): Bluebird => {
return Bluebird.filter(allEditors(), (editor) => {
debug('check if user has editor %s with binary %s', editor.name, editor.binary)
return shell.commandExists(editor.binary)
})
.then((editors: Editor[] = []) => {
debug('user has the following editors: %o', editors)
return savedState.create()
.then((state) => {
return state.get('preferredEditor')
})
.then((preferredEditor?: CyEditor) => {
debug('saved preferred editor: %o', preferredEditor)
return _.map(editors, createEditor).concat([getOtherEditor(preferredEditor)])
})