Repository: atom/atom
File: src/main-process/atom-application.js (JavaScript)

Code before:
      path
    )
  }

  promptForPath (type, callback, path) {
    const properties = (() => {
      switch (type) {
        case 'file': return ['openFile']
        case 'folder': return ['openDirectory']
        case 'all': return ['openFile', 'openDirectory']
        default: throw new Error(`${type} is an invalid type for promptForPath`)
      }
    })()

    // Show the open dialog as child window on Windows and Linux, and as
    // independent dialog on macOS. This matches most native apps.
    const parentWindow = process.platform === 'darwin' ? null : BrowserWindow.getFocusedWindow()

    const openOptions = {
      properties: properties.concat(['multiSelections', 'createDirectory']),
      title: (() => {
        switch (type) {
          case 'file': return 'Open File'
          case 'folder': return 'Open Folder'
          default: return 'Open'
        }
      })()
    }

    // File dialog defaults to project directory of currently active editor
    if (path) openOptions.defaultPath = path
    dialog.showOpenDialog(parentWindow, openOptions, callback)
  }

  promptForRestart () {
    dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
      type: 'warning',
      title: 'Restart required',
      message: 'You will need to restart Atom for this change to take effect.',
      buttons: ['Restart Atom', 'Cancel']
    }, response => { if (response === 0) this.restart() })
  }

  restart () {
    const args = []
    if (this.safeMode) args.push('--safe')
    if (this.logFile != null) args.push(`--log-file=${this.logFile}`)
    if (this.userDataDir != null) args.push(`--user-data-dir=${this.userDataDir}`)
    if (this.devMode) {
      args.push('--dev')
      args.push(`--resource-path=${this.resourcePath}`)

Review comment (suggestion):
Current status: Wishing JavaScript Array provided a [`none` method](https://ruby-doc.org/core-2.6.2/Enumerable.html#method-i-none-3F). 

Code after:
  //           'folder' or 'all'. The 'all' is only available on macOS.
  //   :devMode - A Boolean which controls whether any newly opened windows
  //              should be in dev mode or not.
  //   :safeMode - A Boolean which controls whether any newly opened windows
  //               should be in safe mode or not.
  //   :window - An {AtomWindow} to use for opening selected file paths as long as
  //             all are files.
  //   :path - An optional String which controls the default path to which the
  //           file dialog opens.
  promptForPathToOpen (type, {devMode, safeMode, window}, path = null) {
    return this.promptForPath(
      type,
      async pathsToOpen => {
        let targetWindow

        // Open in :window as long as no chosen paths are folders. If any chosen path is a folder, open in a
        // new window instead.
        if (type === 'folder') {
          targetWindow = null
        } else if (type === 'file') {
          targetWindow = window
        } else if (type === 'all') {
          const areDirectories = await Promise.all(
            pathsToOpen.map(pathToOpen => new Promise(resolve => fs.isDirectory(pathToOpen, resolve)))
          )
          if (!areDirectories.some(Boolean)) {
            targetWindow = window
          }
        }

        return this.openPaths({pathsToOpen, devMode, safeMode, window: targetWindow})
      },
      path
    )
  }

  promptForPath (type, callback, path) {
    const properties = (() => {
      switch (type) {
        case 'file': return ['openFile']
        case 'folder': return ['openDirectory']
        case 'all': return ['openFile', 'openDirectory']
        default: throw new Error(`${type} is an invalid type for promptForPath`)
      }
    })()

    // Show the open dialog as child window on Windows and Linux, and as
    // independent dialog on macOS. This matches most native apps.
    const parentWindow = process.platform === 'darwin' ? null : BrowserWindow.getFocusedWindow()

    const openOptions = {