Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Petru Ilies 2016-04-18 10:35:46 +03:00
commit 58f7a868d7
15 changed files with 233 additions and 66 deletions

View File

@ -68,7 +68,7 @@ before_install:
# - stack setup
# - stack install stylish-haskell
# Elm
- curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.1-alpha2/elm-format-0.1-alpha2-mac-x64.tgz
- curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.2.0-alpha/elm-format-0.2.0-alpha-mac-x64.tgz
- tar xvzf /tmp/elm-format.tgz -C /usr/local/bin
# Crystal
- brew install crystal-lang

View File

@ -76,6 +76,11 @@ install:
- "%CMD_IN_ENV% pip install --upgrade autopep8"
- where autopep8
- "%CMD_IN_ENV% pip install --upgrade isort"
- where isort
- "%CMD_IN_ENV% pip install --upgrade sqlparse"
# Ruby & Gem
- cinst ruby -y
- "SET PATH=C:\\Ruby193\\bin;%PATH%"
@ -105,18 +110,25 @@ install:
- where php-cs-fixer
# Uncrustify
- curl -L http://sourceforge.net/projects/uncrustify/files/uncrustify/uncrustify-0.61/uncrustify-0.61.3-gf65394e-win32.zip/download > uncrustify.zip
- curl -k -L http://sourceforge.net/projects/uncrustify/files/uncrustify/uncrustify-0.61/uncrustify-0.61.3-gf65394e-win32.zip/download -o uncrustify.zip
- cinst 7zip.commandline -y
- 7za e uncrustify.zip -ouncrustify
- "SET PATH=%cd%\\uncrustify;%PATH%"
- 7za e uncrustify.zip -ouncrustify-d
- "SET PATH=%cd%\\uncrustify-d;%PATH%"
- where uncrustify
# elm-format
- curl -k -L https://github.com/avh4/elm-format/releases/download/0.2.0-alpha/elm-format-0.2.0-alpha-win-x64.zip -o elm-format.zip
- 7za e elm-format.zip -oelm-format-d
- "SET PATH=%cd%\\elm-format-d;%PATH%"
- where elm-format
build_script:
- cd %APPVEYOR_BUILD_FOLDER%
# Install languages to Atom
- apm install language-marko language-html-swig language-svg language-elm
- apm install language-marko language-html-swig language-svg language-elm language-d mavensmate-atom
# Show current PATH
- echo %PATH%
# Run tests on package
#- "%LOCALAPPDATA%\\atom\\bin\\atom.cmd --test spec"
- apm test --path %LOCALAPPDATA%/atom/bin/atom.cmd

View File

@ -394,7 +394,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [Coldfusion](#coldfusion)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -1331,7 +1331,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [CSS](#css)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`JS Beautify`](#js-beautify) [`JS Beautify`](#js-beautify) [`JS Beautify`](#js-beautify) [`JS Beautify`](#js-beautify) [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -1720,7 +1720,7 @@ Maximum amount of characters per line (0 = disable) (Supported by JS Beautify, P
#### [CSV](#csv)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -1870,7 +1870,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [EJS](#ejs)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -2172,7 +2172,7 @@ Automatically beautify Elm files on save
#### [ERB](#erb)
**Supported Beautifiers**: [`HTML Beautifier`](#html-beautifier) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`HTML Beautifier`](#html-beautifier) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -2691,7 +2691,7 @@ Automatically beautify Go files on save
#### [Handlebars](#handlebars)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -2722,7 +2722,7 @@ Disable Handlebars Beautification
**Type**: `string`
**Enum**: `JS Beautify`
**Enum**: `JS Beautify` `Pretty Diff`
**Description**:
@ -2844,11 +2844,11 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be
**Type**: `string`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation character (Supported by JS Beautify)
Indentation character (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
@ -2922,11 +2922,11 @@ Indent <head> and <body> sections. (Supported by JS Beautify)
**Type**: `integer`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation size/length (Supported by JS Beautify)
Indentation size/length (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
@ -2974,11 +2974,11 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify)
**Type**: `boolean`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
Preserve line-breaks (Supported by JS Beautify)
Preserve line-breaks (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
@ -3118,11 +3118,11 @@ Indent wrapped attributes to after N characters (Supported by JS Beautify)
**Type**: `integer`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
Maximum characters per line (0 disables) (Supported by JS Beautify)
Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
@ -3199,7 +3199,7 @@ Automatically beautify Haskell files on save
#### [HTML](#html)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -3644,7 +3644,7 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff)
#### [Jade](#jade)
**Supported Beautifiers**: [`Pug Beautify`](#pug-beautify) [`Pug Beautify`](#pug-beautify)
**Supported Beautifiers**: [`Pug Beautify`](#pug-beautify)
**Description**:
@ -3846,7 +3846,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [JavaScript](#javascript)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -4379,7 +4379,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
#### [JSON](#json)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -4912,7 +4912,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
#### [JSX](#jsx)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -5393,7 +5393,7 @@ Remove trailing whitespace (Supported by Latex Beautify)
#### [LESS](#less)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -5758,7 +5758,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Markdown](#markdown)
**Supported Beautifiers**: [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Remark`](#remark) [`Tidy Markdown`](#tidy-markdown)
**Supported Beautifiers**: [`Remark`](#remark) [`Tidy Markdown`](#tidy-markdown)
**Description**:
@ -7461,7 +7461,7 @@ sort imports (requires isort installed) (Supported by autopep8)
#### [Riot.js](#riot.js)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -7628,7 +7628,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [Ruby](#ruby)
**Supported Beautifiers**: [`Rubocop`](#rubocop) [`Rubocop`](#rubocop) [`Ruby Beautify`](#ruby-beautify) [`Ruby Beautify`](#ruby-beautify)
**Supported Beautifiers**: [`Rubocop`](#rubocop) [`Ruby Beautify`](#ruby-beautify)
**Description**:
@ -7856,7 +7856,7 @@ Path to rustfmt program (Supported by rustfmt)
#### [Sass](#sass)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -8221,7 +8221,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [SCSS](#scss)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -8586,7 +8586,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Spacebars](#spacebars)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -8898,7 +8898,7 @@ Change case of keywords (Supported by sqlformat)
#### [SVG](#svg)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -9065,7 +9065,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [Swig](#swig)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -9232,7 +9232,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [TSS](#tss)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -9545,7 +9545,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Twig](#twig)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -10404,7 +10404,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [Visualforce](#visualforce)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
@ -10571,7 +10571,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [XML](#xml)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**:
@ -11016,7 +11016,7 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff)
#### [XTemplate](#xtemplate)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff) [`Pretty Diff`](#pretty-diff)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:

View File

@ -0,0 +1,65 @@
/**
* Created by Pierre on 05.04.16.
*/
var express = require("express");
var router = express.Router({
mergeParams: true
});
var Customer = require("../../models/customers");
var middleware = require("../../middleware/index.js");
//TODO add a way for pagination
//INDEX - show all Customers
router.get("/", function (req, res) {
var regexid = /^[a-f\d]{24}$/i;
var search = req.query.search;
if (regexid.exec(search) !== null) {
Customer.findById(search, function (err, foundCustomer) {
if (err) {
console.log(err);
} else {
res.end(JSON.stringify([foundCustomer]));
}
});
} else {
var re = new RegExp(search);
var offset = 0;
if (req.query.offset) {
offset = req.query.offset;
}
Customer.find().or([{
'name': {
$regex: re
}
}, {
'mail': {
$regex: re
}
}, {
'phone': {
$regex: re
}
}, {
'customernumber': {
$regex: re
}
}, {
'street': {
$regex: re
}
}]).skip(parseInt(offset)).limit(20).exec(function (err, allCustomers) {
if (err) {
console.log(err);
} else if (allCustomers.length === 0) {
res.sendStatus(404);
} else {
res.end(JSON.stringify(allCustomers));
}
});
}
});
// TODO add findsingle for id
module.exports = router;

View File

@ -0,0 +1,66 @@
/**
* Created by Pierre on 05.04.16.
*/
var express = require("express");
var router = express.Router({
mergeParams: true
});
var Customer = require("../../models/customers");
var middleware = require("../../middleware/index.js");
//TODO add a way for pagination
//INDEX - show all Customers
router.get("/", function(req, res) {
var regexid = /^[a-f\d]{24}$/i;
var search = req.query.search;
if (regexid.exec(search) !== null) {
Customer.findById(search, function(err, foundCustomer) {
if (err) {
console.log(err);
} else {
res.end(JSON.stringify([foundCustomer]));
}
});
} else {
var re = new RegExp(search);
var offset = 0;
if (req.query.offset) {
offset = req.query.offset;
}
Customer.find().or([{
'name': {
$regex: re
}
}, {
'mail': {
$regex: re
}
}, {
'phone': {
$regex: re
}
}, {
'customernumber': {
$regex: re
}
}, {
'street': {
$regex: re
}
}]).skip(parseInt(offset)).limit(20).exec(function(err, allCustomers) {
if (err) {
console.log(err);
} else if (allCustomers.length === 0) {
res.sendStatus(404);
} else {
res.end(JSON.stringify(allCustomers));
}
});
}
});
// TODO add findsingle for id
module.exports = router;

View File

@ -1,7 +1,7 @@
{
"name": "atom-beautify",
"main": "./src/beautify",
"version": "0.29.2",
"version": "0.29.4",
"private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom",
"repository": {
@ -88,7 +88,6 @@
"coffee-fmt": "0.11.0",
"coffee-formatter": "^0.1.2",
"coffee-script": "^1.10.0",
"cross-spawn": "^2.0.0",
"csscomb": "^3.1.7",
"diff": "^2.1.0",
"editorconfig": "^0.12.2",
@ -117,6 +116,9 @@
"winston": "^1.0.0",
"yaml-front-matter": "^3.2.3"
},
"optionalDependencies": {
"cross-spawn": "^2.0.0"
},
"activationCommands": {
"atom-workspace": [
"atom-beautify:help-debug-editor",

View File

@ -129,6 +129,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) {
allOptions = _.values(langOptions);
flatOptions = _.reduce(allOptions, (function(result, languageOptions, language) {
return _.reduce(languageOptions, (function(result, optionDef, optionName) {
optionDef.beautifiers = _.uniq(optionDef.beautifiers)
if (optionDef.beautifiers.length > 0) {
optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")";
} else {
@ -309,6 +310,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) {
ref16 = group.properties;
for (o in ref16) {
optionDef = ref16[o];
optionDef.beautifiers = _.uniq(optionDef.beautifiers)
if (optionDef.beautifiers.length > 0) {
optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")";
} else {
@ -324,7 +326,8 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) {
lang = languages[langName];
name = lang.name;
namespace = lang.namespace;
beautifiers = lang.beautifiers;
beautifiers = (lang.beautifiers = _.uniq(lang.beautifiers));
langOptions[namespace].beautifiers = beautifiers
optionName = "language_" + namespace;
_.set(langOptions, namespace + ".properties.disabled", {
title: "Disable Beautifying Language",

View File

@ -2,9 +2,14 @@ Promise = require("bluebird")
_ = require('lodash')
fs = require("fs")
temp = require("temp").track()
spawn = require('cross-spawn')
readFile = Promise.promisify(fs.readFile)
which = require('which')
# Get optional dependency cross-spawn
spawn = null
try
spawn = require('cross-spawn')
catch err
spawn = require('child_process').spawn
module.exports = class Beautifier
@ -319,7 +324,7 @@ module.exports = class Beautifier
for key, method of @logger
# @verbose(key, method)
@[key] = method
@verbose("Beautifier logger has been initialized.")
@verbose("#{@name} beautifier logger has been initialized.")
###
Constructor to setup beautifer

View File

@ -34,14 +34,12 @@ module.exports = class FortranBeautifier extends Beautifier
]
if emacs_path
args.unshift("#{emacs_path}")
@run("python", args, {ignoreReturnCode: true})
@run(emacs_path, args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)
else
@run("emacs", args, {ignoreReturnCode: true})
@run("emacs", args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)

View File

@ -303,7 +303,7 @@ module.exports = class Beautifiers extends EventEmitter
grammar : grammar
extension : fileExtension
version : version
options : allOptions
#options : allOptions
label : language?.name
category : version

View File

@ -40,6 +40,7 @@ module.exports = class PrettyDiff extends Beautifier
ERB: true
EJS: true
HTML: true
Handlebars: true
XML: true
SVG: true
Spacebars: true

View File

@ -180,6 +180,7 @@ beautify = ({onSave}) ->
return
beautifyFilePath = (filePath, callback) ->
logger.verbose('beautifyFilePath', filePath)
# Show in progress indicate on file's tree-view entry
$ ?= require("atom-space-pen-views").$
@ -188,13 +189,16 @@ beautifyFilePath = (filePath, callback) ->
# Cleanup and return callback function
cb = (err, result) ->
logger.verbose('Cleanup beautifyFilePath', err, result)
$el = $(".icon-file-text[data-path=\"#{filePath}\"]")
$el.removeClass('beautifying')
return callback(err, result)
# Get contents of file
fs ?= require "fs"
logger.verbose('readFile', filePath)
fs.readFile(filePath, (err, data) ->
logger.verbose('readFile completed', err, filePath)
return cb(err) if err
input = data?.toString()
grammar = atom.grammars.selectGrammar(filePath, input)
@ -202,14 +206,18 @@ beautifyFilePath = (filePath, callback) ->
# Get the options
allOptions = beautifier.getOptionsForPath(filePath)
logger.verbose('beautifyFilePath allOptions', allOptions)
# Beautify File
completionFun = (output) ->
logger.verbose('beautifyFilePath completionFun', output)
if output instanceof Error
return cb(output, null ) # output == Error
else if typeof output is "string"
# do not allow empty string
return cb(null, output) if output is ''
if output.trim() is ''
logger.verbose('beautifyFilePath, output was empty string!')
return cb(null, output)
# save to file
fs.writeFile(filePath, output, (err) ->
return cb(err) if err
@ -218,6 +226,7 @@ beautifyFilePath = (filePath, callback) ->
else
return cb( new Error("Unknown beautification result #{output}."), output)
try
logger.verbose('beautify', input, allOptions, grammarName, filePath)
beautifier.beautify(input, allOptions, grammarName, filePath)
.then(completionFun)
.catch(completionFun)
@ -470,8 +479,9 @@ debug = () ->
handleSaveEvent = ->
atom.workspace.observeTextEditors (editor) ->
disposable = editor.onDidSave(({path : filePath}) ->
logger.verbose('Should beautify on this save?')
buffer = editor.getBuffer()
disposable = buffer.onDidSave(({path : filePath}) ->
path ?= require('path')
# Get Grammar
grammar = editor.getGrammar().name
@ -492,14 +502,18 @@ handleSaveEvent = ->
if beautifyOnSave
posArray = getCursors(editor)
origScrollTop = getScrollTop(editor)
logger.verbose('Beautifying file', filePath)
beautifyFilePath(filePath, ->
logger.verbose('Done beautifying file', filePath)
if editor.isAlive() is true
logger.verbose('Reloading TextEditor buffer...')
buffer.reload()
logger.verbose('restore editor positions', posArray,origScrollTop)
logger.verbose('Reloaded TextEditor buffer.')
# Let the scrollTop setting run after all the save related stuff is run,
# otherwise setScrollTop is not working, probably because the cursor
# addition happens asynchronously
setTimeout ( ->
logger.verbose('restore editor positions', posArray,origScrollTop)
setCursors(editor, posArray)
setScrollTop(editor, origScrollTop)
# console.log "setScrollTop"

View File

@ -16,14 +16,14 @@ module.exports = {
Supported Grammars
###
grammars: [
"Jade"
"Jade", "Pug"
]
###
Supported extensions
###
extensions: [
"jade"
"jade", "pug"
]
options: [

View File

@ -48,7 +48,7 @@ module.exports = do ->
})
wlogger.on('logging', (transport, level, msg, meta)->
loggerLevel = atom?.config.get(\
'atom-beautify._loggerLevel') ? "warn"
'atom-beautify.general.loggerLevel') ? "warn"
# console.log('logging', loggerLevel, arguments)
loggerLevelNum = levels[loggerLevel]
levelNum = levels[level]
@ -57,7 +57,8 @@ module.exports = do ->
label = "#{path.dirname(transport.label)\
.split(path.sep).reverse()[0]}\
#{path.sep}#{path.basename(transport.label)}"
console.log("#{label} [#{level}]: #{msg}", meta)
d = new Date()
console.log("#{d.toLocaleDateString()} #{d.toLocaleTimeString()} - #{label} [#{level}]: #{msg}", meta)
)
# Export logger methods
loggerMethods = ['silly','debug','verbose','info','warn','error']