<commit_before>import path from 'path'
import isError from '../is-error'
import { promises as fs } from 'fs'
import * as Log from '../../build/output/log'
import * as CommentJson from 'next/dist/compiled/comment-json'

// Write .vscode settings to enable Next.js typescript plugin.
export async function writeVscodeConfigurations(
  baseDir: string
): Promise<void> {
  try {
    const vscodeSettings = path.join(baseDir, '.vscode', 'settings.json')
    let settings: any = {}
    let configExisted = false
    let currentContent: string = ''

    try {
      currentContent = await fs.readFile(vscodeSettings, 'utf8')
      settings = CommentJson.parse(currentContent)
      configExisted = true
    } catch (err) {
      if (isError(err) && err.code !== 'ENOENT') {
        throw err
      }
    }

    const libPath =
      '.' + path.sep + path.join('node_modules', 'typescript', 'lib')
    if (
      settings['typescript.tsdk'] === libPath &&
      settings['typescript.enablePromptUseWorkspaceTsdk']
    ) {
      return
    }

    settings['typescript.tsdk'] = libPath
    settings['typescript.enablePromptUseWorkspaceTsdk'] = true

    const content = CommentJson.stringify(settings, null, 2)
    const vscodeFolder = path.join(baseDir, '.vscode')

    try {
      await fs.lstat(vscodeFolder)
    } catch (e) {
      await fs.mkdir(vscodeFolder, { recursive: true })
    }
    await fs.writeFile(vscodeSettings, content)

    Log.info(<commit_msg>Stop writing window specific paths in vscode configuration (#42338)<commit_after>import path from 'path'
import isError from '../is-error'
import { promises as fs } from 'fs'
import * as Log from '../../build/output/log'
import * as CommentJson from 'next/dist/compiled/comment-json'

// Write .vscode settings to enable Next.js typescript plugin.
export async function writeVscodeConfigurations(
  baseDir: string
): Promise<void> {
  try {
    const vscodeSettings = path.join(baseDir, '.vscode', 'settings.json')
    let settings: any = {}
    let configExisted = false
    let currentContent: string = ''

    try {
      currentContent = await fs.readFile(vscodeSettings, 'utf8')
      settings = CommentJson.parse(currentContent)
      configExisted = true
    } catch (err) {
      if (isError(err) && err.code !== 'ENOENT') {
        throw err
      }
    }

    const libPath = './node_modules/typescript/lib'
    if (
      settings['typescript.tsdk'] === libPath &&
      settings['typescript.enablePromptUseWorkspaceTsdk']
    ) {
      return
    }

    settings['typescript.tsdk'] = libPath
    settings['typescript.enablePromptUseWorkspaceTsdk'] = true

    const content = CommentJson.stringify(settings, null, 2)
    const vscodeFolder = path.join(baseDir, '.vscode')

    try {
      await fs.lstat(vscodeFolder)
    } catch (e) {
      await fs.mkdir(vscodeFolder, { recursive: true })
    }
    await fs.writeFile(vscodeSettings, content)

    Log.info(
{'fraction_non_alphanumeric': 0.12286689419795221, 'fraction_numerical': 0.0030716723549488053, 'mean_word_length': 3.1050420168067228, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3831512', 'n_tokens_mistral': 918, 'n_tokens_neox': 903, 'n_words': 220}