{"size": 435, "ext": "js", "max_stars_repo_path": "ui/server/graphql/handler/cwd.js", "max_stars_repo_name": "fossabot/mock-server", "max_stars_repo_stars_event_min_datetime": "2018-01-03T03:49:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-12-16T01:41:19.000Z", "max_issues_repo_path": "ui/server/graphql/handler/cwd.js", "max_issues_repo_name": "fossabot/mock-server", "max_issues_repo_issues_event_min_datetime": "2019-12-28T21:56:51.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-09T16:27:04.000Z", "max_forks_repo_path": "ui/server/graphql/handler/cwd.js", "max_forks_repo_name": "fossabot/mock-server", "max_forks_repo_forks_event_min_datetime": "2019-09-07T04:41:07.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-07T04:41:07.000Z"}
{"max_stars_count": 10, "max_issues_count": 6, "max_forks_count": 1, "avg_line_length": 18.9130434783, "max_line_length": 49, "alphanum_fraction": 0.6114942529}
const fs = require('fs')
const path = require('path')

let cwd = process.cwd()

function normalize(value) {
  if (value.length === 1) return value
  const lastChar = value.charAt(value.length - 1)
  if (lastChar === path.sep) {
    value = value.substr(0, value.length - 1)
  }
  return value
}

module.exports = {
  get: () => cwd,
  set: file => {
    file = normalize(file)
    if (!fs.existsSync(file)) return
    cwd = file
  }
}
