<commit_before>library polymer.tool.uncomment_test_section_in_pubspec;

import 'dart:io';

import 'package:path/path.dart';

main() {
  var path = relative(
      join(dirname(dirname(Platform.script.path.substring(1))), 'pubspec.yaml'));
  print('uncomment_test_section_in_pubspec: processing $path');
  var pubspec = new File(path);
  if (!pubspec.existsSync()) {
    print('uncomment_test_section_in_pubspec error: '
        'pubspec.yaml not found: $path.');
    exit(1);
  }
  var contents = pubspec.readAsStringSync();
  var begin = contents.indexOf("# ---prehook: begin uncomment---");
  if (begin == -1) {
    print('uncomment_test_section_in_pubspec error: '
        'start of commented section not found.');
    exit(1);
  }
  var end = contents.indexOf("# ---prehook: end uncomment---", begin);
  if (end == -1) {
    print('uncomment_test_section_in_pubspec error: '
        'end of commented section not found.');
    exit(1);
  }
  var newContents = new StringBuffer()
      ..write(contents.substring(0, begin))
      ..write(contents.substring(begin, end).replaceAll('\n# ', '\n'))
      ..write(contents.substring(end));
  pubspec.writeAsStringSync(newContents.toString());
  print('updated pubspec successfully');<commit_msg>Remove relative path, but do special check for windows<commit_after>library polymer.tool.uncomment_test_section_in_pubspec;

import 'dart:io';

import 'package:path/path.dart';

main() {
  var scriptPath = Platform.script.path;
  if (context.style.name == 'windows') scriptPath = scriptPath.substring(1);
  var path = join(dirname(dirname(scriptPath)), 'pubspec.yaml');
  print('uncomment_test_section_in_pubspec: processing $path');
  var pubspec = new File(path);
  if (!pubspec.existsSync()) {
    print('uncomment_test_section_in_pubspec error: '
        'pubspec.yaml not found: $path.');
    exit(1);
  }
  var contents = pubspec.readAsStringSync();
  var begin = contents.indexOf("# ---prehook: begin uncomment---");
  if (begin == -1) {
    print('uncomment_test_section_in_pubspec error: '
        'start of commented section not found.');
    exit(1);
  }
  var end = contents.indexOf("# ---prehook: end uncomment---", begin);
  if (end == -1) {
    print('uncomment_test_section_in_pubspec error: '
        'end of commented section not found.');
    exit(1);
  }
  var newContents = new StringBuffer()
      ..write(contents.substring(0, begin))
      ..write(contents.substring(begin, end).replaceAll('\n# ', '\n'))
      ..write(contents.substring(end));
  pubspec.writeAsStringSync(newContents.toString());
  print('updated pubspec successfully');
{'fraction_non_alphanumeric': 0.1547024952015355, 'fraction_numerical': 0.005374280230326296, 'mean_word_length': 4.040618955512572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3007201', 'n_tokens_mistral': 817, 'n_tokens_neox': 824, 'n_words': 178}