diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 720924a09..cdca7392a 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -29,6 +29,7 @@ module.exports = (grunt) -> grunt.loadNpmTasks('grunt-markdown') grunt.loadNpmTasks('grunt-shell') grunt.loadNpmTasks('grunt-download-atom-shell') + grunt.loadNpmTasks('grunt-peg') grunt.loadTasks('tasks') # This allows all subsequent paths to the relative to the root of the repo @@ -106,6 +107,13 @@ module.exports = (grunt) -> dest: appDir ext: '.json' + pegConfig = + glob_to_multiple: + expand: true + src: ['src/**/*.pegjs'] + dest: appDir + ext: '.js' + for child in fs.readdirSync('node_modules') when child isnt '.bin' directory = path.join('node_modules', child) {engines, theme} = grunt.file.readJSON(path.join(directory, 'package.json')) @@ -114,6 +122,7 @@ module.exports = (grunt) -> lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less") prebuildLessConfig.src.push("#{directory}/**/*.less") unless theme csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson") + pegConfig.glob_to_multiple.src.push("#{directory}/**/*.pegjs") grunt.initConfig pkg: grunt.file.readJSON('package.json') @@ -128,6 +137,8 @@ module.exports = (grunt) -> cson: csonConfig + peg: pegConfig + coffeelint: options: no_empty_param_list: @@ -211,10 +222,10 @@ module.exports = (grunt) -> stderr: false failOnError: false - grunt.registerTask('compile', ['coffee', 'prebuild-less', 'cson']) + grunt.registerTask('compile', ['coffee', 'prebuild-less', 'cson', 'peg']) grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint']) grunt.registerTask('test', ['shell:kill-atom', 'run-specs']) - grunt.registerTask('ci', ['download-atom-shell', 'build', 'set-development-version', 'lint', 'test', 'publish-build']) + grunt.registerTask('ci', ['output-disk-space', 'download-atom-shell', 'build', 'set-development-version', 'lint', 'test', 'publish-build']) grunt.registerTask('deploy', ['partial-clean', 'download-atom-shell', 'build', 'codesign']) grunt.registerTask('docs', ['markdown:guides', 'build-docs']) grunt.registerTask('default', ['download-atom-shell', 'build', 'set-development-version', 'install']) diff --git a/build/package.json b/build/package.json index 5baf8e732..6961520fd 100644 --- a/build/package.json +++ b/build/package.json @@ -29,6 +29,7 @@ "rimraf": "~2.2.2", "unzip": "~0.1.9", "vm-compatibility-layer": "~0.1.0", - "walkdir": "0.0.7" + "walkdir": "0.0.7", + "grunt-peg": "~1.1.0" } } diff --git a/build/tasks/output-disk-space.coffee b/build/tasks/output-disk-space.coffee new file mode 100644 index 000000000..372ead672 --- /dev/null +++ b/build/tasks/output-disk-space.coffee @@ -0,0 +1,25 @@ +module.exports = (grunt) -> + {spawn} = require('./task-helpers')(grunt) + + grunt.registerTask 'output-disk-space', 'Print diskspace available', -> + return unless process.platform is 'darwin' + + done = @async() + + cmd = 'df' + args = ['-Hl'] + spawn {cmd, args}, (error, result, code) -> + return done(error) if error? + + lines = result.stdout.split("\n") + + for line in lines[1..] + [filesystem, size, used, avail, capacity, extra] = line.split(/\s+/) + capacity = parseInt(capacity) + + if capacity > 90 + grunt.log.error("#{filesystem} is at #{capacity}% capacity!") + else if capacity > 80 + grunt.log.ok("#{filesystem} is at #{capacity}% capacity.") + + done() diff --git a/build/tasks/task-helpers.coffee b/build/tasks/task-helpers.coffee index 4362393d0..f83430884 100644 --- a/build/tasks/task-helpers.coffee +++ b/build/tasks/task-helpers.coffee @@ -39,7 +39,7 @@ module.exports = (grunt) -> proc = childProcess.spawn(options.cmd, options.args, options.opts) proc.stdout.on 'data', (data) -> stdout.push(data.toString()) proc.stderr.on 'data', (data) -> stderr.push(data.toString()) - proc.on 'exit', (exitCode, signal) -> + proc.on 'close', (exitCode, signal) -> error = new Error(signal) if exitCode != 0 results = {stderr: stderr.join(''), stdout: stdout.join(''), code: exitCode} grunt.log.error results.stderr if exitCode != 0 diff --git a/package.json b/package.json index 852518566..743b79747 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "coffee-script": "1.6.3", "coffeestack": "0.6.0", "emissary": "0.19.0", - "first-mate": "0.13.0", + "first-mate": "0.17.0", "fs-plus": "0.14.0", "fstream": "0.1.24", - "fuzzaldrin": "0.5.0", + "fuzzaldrin": "0.6.0", "git-utils": "0.30.0", "guid": "0.0.10", "jasmine-focused": "~0.15.0", @@ -41,7 +41,7 @@ "oniguruma": "0.26.0", "optimist": "0.4.0", "pathwatcher": "0.13.0", - "pegjs": "0.7.0", + "pegjs": "0.8.0", "q": "0.9.7", "scandal": "0.11.0", "season": "0.14.0", @@ -49,9 +49,9 @@ "space-pen": "3.0.3", "temp": "0.5.0", "text-buffer": "0.12.0", + "theorist": "~0.7.0", "underscore-plus": "0.6.1", - "vm-compatibility-layer": "0.1.0", - "theorist": "~0.7.0" + "vm-compatibility-layer": "0.1.0" }, "packageDependencies": { "atom-dark-syntax": "0.10.0", @@ -65,16 +65,16 @@ "autocomplete": "0.19.0", "autoflow": "0.11.0", "autosave": "0.10.0", - "background-tips": "0.3.0", + "background-tips": "0.4.0", "bookmarks": "0.15.0", "bracket-matcher": "0.16.0", "command-logger": "0.9.0", "command-palette": "0.14.0", "dev-live-reload": "0.22.0", "editor-stats": "0.12.0", - "exception-reporting": "0.9.0", + "exception-reporting": "0.11.0", "feedback": "0.22.0", - "find-and-replace": "0.68.0", + "find-and-replace": "0.73.0", "fuzzy-finder": "0.30.0", "gists": "0.14.0", "git-diff": "0.21.0", @@ -83,21 +83,21 @@ "grammar-selector": "0.16.0", "image-view": "0.14.0", "keybinding-resolver": "0.8.0", - "markdown-preview": "0.22.0", - "metrics": "0.20.0", + "markdown-preview": "0.23.0", + "metrics": "0.21.0", "package-generator": "0.23.0", "release-notes": "0.15.0", "settings-view": "0.55.0", - "snippets": "0.17.0", + "snippets": "0.18.0", "spell-check": "0.19.0", - "status-bar": "0.30.0", + "status-bar": "0.31.0", "styleguide": "0.19.0", "symbols-view": "0.28.0", "tabs": "0.16.0", "terminal": "0.24.0", "timecop": "0.12.0", "to-the-hubs": "0.17.0", - "tree-view": "0.58.0", + "tree-view": "0.59.0", "visual-bell": "0.6.0", "welcome": "0.4.0", "whitespace": "0.10.0", diff --git a/src/atom-package.coffee b/src/atom-package.coffee index aa62359e9..6546945bb 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -52,12 +52,6 @@ class AtomPackage extends Package console.warn "Failed to load package named '#{@name}'", e.stack ? e this - enable: -> - atom.config.removeAtKeyPath('core.disabledPackages', @metadata.name) - - disable: -> - atom.config.pushAtKeyPath('core.disabledPackages', @metadata.name) - reset: -> @stylesheets = [] @keymaps = [] diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 3e9aacc18..fa18a59c1 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -52,6 +52,8 @@ class AtomApplication resourcePath: null version: null + exit: (status) -> app.exit(status) + constructor: (options) -> {@resourcePath, @version, @devMode} = options global.atomApplication = this diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index 9a15c251b..0f09bfaa4 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -18,7 +18,7 @@ class AtomWindow isSpec: null constructor: (settings={}) -> - {@resourcePath, pathToOpen, initialLine, @isSpec} = settings + {@resourcePath, pathToOpen, initialLine, @isSpec, @exitWhenDone} = settings global.atomApplication.addWindow(this) @setupNodePath(@resourcePath) @@ -82,7 +82,7 @@ class AtomWindow @browserWindow.destroy() if chosen is 0 @browserWindow.on 'crashed', => - atom.exit(100) if @isSpec + global.atomApplication.exit(100) if @exitWhenDone chosen = dialog.showMessageBox @browserWindow, type: 'warning' diff --git a/src/display-buffer-marker.coffee b/src/display-buffer-marker.coffee index 1bbd6633e..8c08b3c9e 100644 --- a/src/display-buffer-marker.coffee +++ b/src/display-buffer-marker.coffee @@ -168,7 +168,7 @@ class DisplayBufferMarker # Returns a {String} representation of the marker inspect: -> - "DisplayBufferMarker(id: #{@id}, bufferRange: #{@getBufferRange().inspect()})" + "DisplayBufferMarker(id: #{@id}, bufferRange: #{@getBufferRange()})" ### Internal ### diff --git a/src/key-binding.coffee b/src/key-binding.coffee index 11b4505d0..1f3ad1d65 100644 --- a/src/key-binding.coffee +++ b/src/key-binding.coffee @@ -1,8 +1,6 @@ -{$} = require './space-pen-extensions' _ = require 'underscore-plus' fs = require 'fs-plus' {specificity} = require 'clear-cut' -PEG = require 'pegjs' ### Internal ### @@ -10,28 +8,41 @@ module.exports = class KeyBinding @parser: null @currentIndex: 1 + @specificities: null + + @calculateSpecificity: (selector) -> + @specificities ?= {} + value = @specificities[selector] + unless value? + value = specificity(selector) + @specificities[selector] = value + value @normalizeKeystroke: (keystroke) -> normalizedKeystroke = keystroke.split(/\s+/).map (keystroke) => - keys = @getParser().parse(keystroke) + keys = @parseKeystroke(keystroke) modifiers = keys[0...-1] modifiers.sort() [modifiers..., _.last(keys)].join('-') normalizedKeystroke.join(' ') - @getParser: -> - if not KeyBinding.parser - keystrokePattern = fs.readFileSync(require.resolve('./keystroke-pattern.pegjs'), 'utf8') - KeyBinding.parser = PEG.buildParser(keystrokePattern) + @parseKeystroke: (keystroke) -> + unless @parser? + try + @parser = require './keystroke-pattern' + catch + keystrokePattern = fs.readFileSync(require.resolve('./keystroke-pattern.pegjs'), 'utf8') + PEG = require 'pegjs' + @parser = PEG.buildParser(keystrokePattern) - KeyBinding.parser + @parser.parse(keystroke) constructor: (source, command, keystroke, selector) -> @source = source @command = command @keystroke = KeyBinding.normalizeKeystroke(keystroke) @selector = selector.replace(/!important/g, '') - @specificity = specificity(selector) + @specificity = KeyBinding.calculateSpecificity(selector) @index = KeyBinding.currentIndex++ matches: (keystroke) -> diff --git a/src/package.coffee b/src/package.coffee index 4d8112466..f7dac9ffe 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -47,6 +47,12 @@ class Package isActive: -> atom.packages.isPackageActive(@name) + enable: -> + atom.config.removeAtKeyPath('core.disabledPackages', @metadata.name) + + disable: -> + atom.config.pushAtKeyPath('core.disabledPackages', @metadata.name) + isTheme: -> !!@metadata?.theme diff --git a/src/pane-container.coffee b/src/pane-container.coffee index 4ecda8359..7f9bd44f7 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -66,7 +66,7 @@ class PaneContainer extends View panes[nextIndex].makeActive() itemDestroyed: (item) -> - @trigger 'item-destroyed', item + @trigger 'item-destroyed', [item] getRoot: -> @children().first().view() diff --git a/src/project.coffee b/src/project.coffee index 7a32a933e..333f5c7bc 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -300,7 +300,7 @@ class Project extends Model promise = deferred.promise promise.cancel = -> task.terminate() - deferred.reject('cancelled') + deferred.resolve('cancelled') promise # Public: Performs a replace across all the specified files in the project. diff --git a/src/task.coffee b/src/task.coffee index de8d3de10..80eaa81b8 100644 --- a/src/task.coffee +++ b/src/task.coffee @@ -91,6 +91,7 @@ class Task # * message: # The message to send send: (message) -> + throw new Error("Cannot send message to terminated process") unless @childProcess? @childProcess.send(message) # Public: Forcefully stop the running task.