{"size": 655, "ext": "js", "max_stars_repo_path": "src/runHacking.js", "max_stars_repo_name": "tennekey/bitburner", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/runHacking.js", "max_issues_repo_name": "tennekey/bitburner", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/runHacking.js", "max_forks_repo_name": "tennekey/bitburner", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.1923076923, "max_line_length": 58, "alphanum_fraction": 0.6351145038}
import {
  localeHHMMSS
} from 'common.js'

export async function main(ns) {
  ns.print(`[${localeHHMMSS()}] Starting runHacking`)

  let hostname = ns.getHostname()

  if (hostname !== 'home') {
    throw new Exception('Run the script from home')
  }

  const homeRam = ns.getServerMaxRam('home')

  if (homeRam >= 32) {
    ns.print(`[${localeHHMMSS()}] Spawning spider`)
    await ns.run('spider.js', 1, 'mainHack.js')
    await ns.asleep(3000)
    ns.print(`[${localeHHMMSS()}] Spawning playerServers`)
    ns.spawn('playerServers.js', 1)
  } else {
    ns.print(`[${localeHHMMSS()}] Spawning spider`)
    ns.spawn('spider.js', 1, 'mainHack.js')
  }
}