<commit_before>import * as Path from 'path'
import { spawn } from 'child_process'
import { pathExists } from '../file-system'
import { ExternalEditor } from '../../models/editors'
import { LookupResult, FoundEditor } from './shared'

import { assertNever } from '../fatal-error'

// This is a stripped back version of winreg:
// https://github.com/fresc81/node-winreg
//
// I was seeing significant overhead when spawning the process to enumerate
// the keys found by `reg.exe`, and rather than trying to fix and potentially
// regress other parts I've extracted just the bit that I need to use.

const regPath = Path.join(process.env.windir, 'System32', 'reg.exe')

const ITEM_PATTERN = /^(.*)\s(REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)\s+([^\s].*)$/

interface IRegistryEntry {
  readonly name: string
  readonly type: string
  readonly value: string
}

/**<commit_msg>handle scenario where platform isn't windows<commit_after>import * as Path from 'path'
import { spawn } from 'child_process'
import { pathExists } from '../file-system'
import { ExternalEditor } from '../../models/editors'
import { LookupResult, FoundEditor } from './shared'

import { assertNever } from '../fatal-error'

// This is a stripped back version of winreg:
// https://github.com/fresc81/node-winreg
//
// I was seeing significant overhead when spawning the process to enumerate
// the keys found by `reg.exe`, and rather than trying to fix and potentially
// regress other parts I've extracted just the bit that I need to use.

const windir = process.env.windir || 'C:\\Windows'
const regPath = Path.join(windir, 'System32', 'reg.exe')

const ITEM_PATTERN = /^(.*)\s(REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)\s+([^\s].*)$/

interface IRegistryEntry {
  readonly name: string
  readonly type: string
  readonly value: string
}

/**
{'fraction_non_alphanumeric': 0.13138297872340426, 'fraction_numerical': 0.00425531914893617, 'mean_word_length': 4.225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2333383', 'n_tokens_mistral': 608, 'n_tokens_neox': 580, 'n_words': 191}