<commit_before>fs = require 'fs'
path = require 'path'

fm = require 'json-front-matter'
_ = require 'underscore'

packageJson = require './package.json'

module.exports = (grunt) ->
  appName = 'Atom.app'
  [major, minor, patch] = packageJson.version.split('.')
  buildDir = grunt.option('build-dir') ? '/tmp/atom-build'
  shellAppDir = path.join(buildDir, appName)
  contentsDir = path.join(shellAppDir, 'Contents')
  appDir = path.join(contentsDir, 'Resources', 'app')
  installDir = path.join('/Applications', appName)

  coffeeConfig =
    options:
      sourceMap: true
    glob_to_multiple:
      expand: true
      src: [
        'src/**/*.coffee'
        'static/**/*.coffee'
      ]
      dest: appDir
      ext: '.js'

  lessConfig =
    options:
      paths: [
        'static'
        'vendor'
      ]
    glob_to_multiple:
      expand: true
      src: [
        'src/**/*.less'
        'static/**/*.less'
        'themes/**/*.less'
      ]
      dest: appDir
      ext: '.css'

  csonConfig =
    options:
      rootObject: true
    glob_to_multiple:
      expand: true
      src: [
        'keymaps/*.cson'
        'src/**/*.cson'
        'static/**/*.cson'
        'themes/**/*.cson'
      ]
      dest: appDir
      ext: '.json'

  for child in fs.readdirSync('node_modules') when child isnt '.bin'
    directory = path.join('node_modules', child)
    {engines} = grunt.file.readJSON(path.join(directory, 'package.json'))
    if engines?.atom?
      coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
      lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
      csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")

  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    atom: {appDir, appName, buildDir, contentsDir, installDir, shellAppDir}

    coffee: coffeeConfig

    less: lessConfig

    cson: csonConfig

    coffeelint:
      options:
        no_empty_param_list:
          level: 'error'
        max_line_length:
          level: 'ignore'
      src: [
        'dot-atom/**/*.coffee'
        'src/**/*.coffee'
      ]
      test: [
        'spec/*.coffee'
        'spec/app/**/*.coffee'
        'spec/stdlib/**/*.coffee'
      ]

    csslint:
      options:
        'adjoining-classes': false
        'box-model': false
        'box-sizing': false
        'bulletproof-font-face': false
        'compatible-vendor-prefixes': false
        'display-property-grouping': false
        'fallback-colors': false
        'font-sizes': false
        'gradients': false
        'ids': false
        'important': false
        'known-properties': false
        'outline-none': false
        'overqualified-elements': false
        'qualified-headings': false
        'unique-headings': false
        'universal-selector': false
        'vendor-prefix': false
      src: [
        'src/**/*.css',
        'static/**/*.css'
        'themes/**/*.css'
      ]

    lesslint:
      src: [
        'src/**/*.less',
        'static/**/*.less'
        'themes/**/*.less'
      ]

    markdown:
      guides:
        files: [
          expand: true
          cwd: 'docs'
          src: '**/*.md'
          dest: 'docs/output/'
          ext: '.html'
        ]
        options:
          template: 'docs/template.jst'
          templateContext:
            tag: "v#{major}.#{minor}"
          markdownOptions:
            gfm: true
          preCompile: (src, context) ->
            parsed = fm.parse(src)
            _.extend(context, parsed.attributes)
            parsed.body

    shell:
      'kill-atom':
        command: 'pkill Atom'
        options:
          stdout: false
          stderr: false
          failOnError: false

      test:
        command: "#{path.join(contentsDir, 'MacOS', 'Atom')} --test --resource-path=#{__dirname}"
        options:
          stdout: false
          stderr: false
          callback: (error, stdout, stderr) -> grunt.warn('Specs failed')

  grunt.loadNpmTasks('grunt-coffeelint')
  grunt.loadNpmTasks('grunt-lesslint')
  grunt.loadNpmTasks('grunt-cson')
  grunt.loadNpmTasks('grunt-contrib-csslint')
  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-contrib-less')
  grunt.loadNpmTasks('grunt-markdown')
  grunt.loadNpmTasks('grunt-shell')
  grunt.loadTasks('tasks')

  grunt.registerTask('compile', ['coffee', 'less', 'cson'])
  grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint'])
  grunt.registerTask('test', ['shell:kill-atom', 'shell:test'])
  grunt.registerTask('ci', ['lint', 'partial-clean', 'update-atom-shell', 'build', 'set-development-version', 'test'])
  grunt.registerTask('deploy', ['partial-clean', 'update-atom-shell', 'build', 'codesign'])
  grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
  grunt.registerTask('default', ['update-atom-shell', 'build', 'set-development-version', 'install'])<commit_msg>Only log warning if error occurs<commit_after>fs = require 'fs'
path = require 'path'

fm = require 'json-front-matter'
_ = require 'underscore'

packageJson = require './package.json'

module.exports = (grunt) ->
  appName = 'Atom.app'
  [major, minor, patch] = packageJson.version.split('.')
  buildDir = grunt.option('build-dir') ? '/tmp/atom-build'
  shellAppDir = path.join(buildDir, appName)
  contentsDir = path.join(shellAppDir, 'Contents')
  appDir = path.join(contentsDir, 'Resources', 'app')
  installDir = path.join('/Applications', appName)

  coffeeConfig =
    options:
      sourceMap: true
    glob_to_multiple:
      expand: true
      src: [
        'src/**/*.coffee'
        'static/**/*.coffee'
      ]
      dest: appDir
      ext: '.js'

  lessConfig =
    options:
      paths: [
        'static'
        'vendor'
      ]
    glob_to_multiple:
      expand: true
      src: [
        'src/**/*.less'
        'static/**/*.less'
        'themes/**/*.less'
      ]
      dest: appDir
      ext: '.css'

  csonConfig =
    options:
      rootObject: true
    glob_to_multiple:
      expand: true
      src: [
        'keymaps/*.cson'
        'src/**/*.cson'
        'static/**/*.cson'
        'themes/**/*.cson'
      ]
      dest: appDir
      ext: '.json'

  for child in fs.readdirSync('node_modules') when child isnt '.bin'
    directory = path.join('node_modules', child)
    {engines} = grunt.file.readJSON(path.join(directory, 'package.json'))
    if engines?.atom?
      coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
      lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
      csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")

  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    atom: {appDir, appName, buildDir, contentsDir, installDir, shellAppDir}

    coffee: coffeeConfig

    less: lessConfig

    cson: csonConfig

    coffeelint:
      options:
        no_empty_param_list:
          level: 'error'
        max_line_length:
          level: 'ignore'
      src: [
        'dot-atom/**/*.coffee'
        'src/**/*.coffee'
      ]
      test: [
        'spec/*.coffee'
        'spec/app/**/*.coffee'
        'spec/stdlib/**/*.coffee'
      ]

    csslint:
      options:
        'adjoining-classes': false
        'box-model': false
        'box-sizing': false
        'bulletproof-font-face': false
        'compatible-vendor-prefixes': false
        'display-property-grouping': false
        'fallback-colors': false
        'font-sizes': false
        'gradients': false
        'ids': false
        'important': false
        'known-properties': false
        'outline-none': false
        'overqualified-elements': false
        'qualified-headings': false
        'unique-headings': false
        'universal-selector': false
        'vendor-prefix': false
      src: [
        'src/**/*.css',
        'static/**/*.css'
        'themes/**/*.css'
      ]

    lesslint:
      src: [
        'src/**/*.less',
        'static/**/*.less'
        'themes/**/*.less'
      ]

    markdown:
      guides:
        files: [
          expand: true
          cwd: 'docs'
          src: '**/*.md'
          dest: 'docs/output/'
          ext: '.html'
        ]
        options:
          template: 'docs/template.jst'
          templateContext:
            tag: "v#{major}.#{minor}"
          markdownOptions:
            gfm: true
          preCompile: (src, context) ->
            parsed = fm.parse(src)
            _.extend(context, parsed.attributes)
            parsed.body

    shell:
      'kill-atom':
        command: 'pkill Atom'
        options:
          stdout: false
          stderr: false
          failOnError: false

      test:
        command: "#{path.join(contentsDir, 'MacOS', 'Atom')} --test --resource-path=#{__dirname}"
        options:
          stdout: true
          stderr: true
          callback: (error, stdout, stderr) ->
            grunt.warn('Specs failed') if error?

  grunt.loadNpmTasks('grunt-coffeelint')
  grunt.loadNpmTasks('grunt-lesslint')
  grunt.loadNpmTasks('grunt-cson')
  grunt.loadNpmTasks('grunt-contrib-csslint')
  grunt.loadNpmTasks('grunt-contrib-coffee')
  grunt.loadNpmTasks('grunt-contrib-less')
  grunt.loadNpmTasks('grunt-markdown')
  grunt.loadNpmTasks('grunt-shell')
  grunt.loadTasks('tasks')

  grunt.registerTask('compile', ['coffee', 'less', 'cson'])
  grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint'])
  grunt.registerTask('test', ['shell:kill-atom', 'shell:test'])
  grunt.registerTask('ci', ['lint', 'partial-clean', 'update-atom-shell', 'build', 'set-development-version', 'test'])
  grunt.registerTask('deploy', ['partial-clean', 'update-atom-shell', 'build', 'codesign'])
  grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
  grunt.registerTask('default', ['update-atom-shell', 'build', 'set-development-version', 'install'])
{'fraction_non_alphanumeric': 0.162534435261708, 'fraction_numerical': 0.0, 'mean_word_length': 2.2414021164021163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2306878', 'n_tokens_mistral': 3261, 'n_tokens_neox': 3192, 'n_words': 568}