How to use the readline-sync.questionPath function in readline-sync

To help you get started, we’ve selected a few readline-sync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asamuzaK / withExEditorHost / modules / setup.js View on Github external
const handleEditorPathInput = async editorFilePath => {
  let editorPath;
  if (isFile(editorFilePath) && isExecutable(editorFilePath)) {
    editorPath = editorFilePath;
  } else {
    const ans = readline.questionPath("Input editor path: ", {
      isFile: true,
    });
    if (isExecutable(ans)) {
      editorPath = ans;
    } else {
      console.warn(`${ans} is not executable.`);
      editorPath = await handleEditorPathInput();
    }
  }
  return editorPath;
};