<commit_before>exec = require("child_process").exec
path = require('path')
fs = require('fs')

module.exports =

  configDefaults: {
    app: 'Terminal.app'
    args: ''
    win32App: 'cmd'
    win32Args: ''
  },

  activate: ->
    atom.workspaceView.command "open-terminal-here:open", => @open()

  open: ->
    isDarwin = document.body.classList.contains("platform-darwin")
    isWin32 = document.body.classList.contains("platform-win32")

    filepath = atom.workspaceView.find('.tree-view .selected').views()?[0][0].getPath?()

    dirpath = filepath

    if fs.lstatSync(filepath).isFile()
        dirpath = path.dirname(filepath)

    return if not dirpath

    if isDarwin
      @openDarwin dirpath
    else #isWin32
      @openWin32 dirpath

  openDarwin: (dirpath) ->
    app = atom.config.get('open-terminal-here.app')
    args = atom.config.get('open-terminal-here.args')
    exec "open -a #{app} #{args} #{dirpath}"

  openWin32: (dirpath) ->
    app = atom.config.get('open-terminal-here.win32App')
    args = atom.config.get('open-terminal-here.win32Args')
    exec "start /D #{dirpath} #{app} #{args}"<commit_msg>Replace deprecated atom.workspaceView references.<commit_after>exec = require("child_process").exec
path = require('path')
fs = require('fs')

module.exports =

  configDefaults: {
    app: 'Terminal.app'
    args: ''
    win32App: 'cmd'
    win32Args: ''
  },

  activate: ->
    atom.commands.add '.tree-view .selected',
      'open-terminal-here:open': (event) => @open(event.currentTarget)

  open: (target) ->
    isDarwin = document.body.classList.contains("platform-darwin")
    isWin32 = document.body.classList.contains("platform-win32")

    filepath = target.getPath?() ? target.item?.getPath()

    dirpath = filepath

    if fs.lstatSync(filepath).isFile()
      dirpath = path.dirname(filepath)

    return if not dirpath

    if isDarwin
      @openDarwin dirpath
    else #isWin32
      @openWin32 dirpath

  openDarwin: (dirpath) ->
    app = atom.config.get('open-terminal-here.app')
    args = atom.config.get('open-terminal-here.args')
    exec "open -a #{app} #{args} #{dirpath}"

  openWin32: (dirpath) ->
    app = atom.config.get('open-terminal-here.win32App')
    args = atom.config.get('open-terminal-here.win32Args')
    exec "start /D #{dirpath} #{app} #{args}"
{'fraction_non_alphanumeric': 0.16048317515099222, 'fraction_numerical': 0.01639344262295082, 'mean_word_length': 3.350844277673546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788975', 'n_tokens_mistral': 833, 'n_tokens_neox': 777, 'n_words': 142}