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 setup
# - stack install stylish-haskell # - stack install stylish-haskell
# Elm # 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 - tar xvzf /tmp/elm-format.tgz -C /usr/local/bin
# Crystal # Crystal
- brew install crystal-lang - brew install crystal-lang

View File

@ -76,6 +76,11 @@ install:
- "%CMD_IN_ENV% pip install --upgrade autopep8" - "%CMD_IN_ENV% pip install --upgrade autopep8"
- where autopep8 - where autopep8
- "%CMD_IN_ENV% pip install --upgrade isort"
- where isort
- "%CMD_IN_ENV% pip install --upgrade sqlparse"
# Ruby & Gem # Ruby & Gem
- cinst ruby -y - cinst ruby -y
- "SET PATH=C:\\Ruby193\\bin;%PATH%" - "SET PATH=C:\\Ruby193\\bin;%PATH%"
@ -105,18 +110,25 @@ install:
- where php-cs-fixer - where php-cs-fixer
# Uncrustify # 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 - cinst 7zip.commandline -y
- 7za e uncrustify.zip -ouncrustify - 7za e uncrustify.zip -ouncrustify-d
- "SET PATH=%cd%\\uncrustify;%PATH%" - "SET PATH=%cd%\\uncrustify-d;%PATH%"
- where uncrustify - 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: build_script:
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
# Install languages to Atom # 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 # Show current PATH
- echo %PATH% - echo %PATH%
# Run tests on package # Run tests on package
#- "%LOCALAPPDATA%\\atom\\bin\\atom.cmd --test spec"
- apm test --path %LOCALAPPDATA%/atom/bin/atom.cmd - 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) #### [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**: **Description**:
@ -1331,7 +1331,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [CSS](#css) #### [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**: **Description**:
@ -1720,7 +1720,7 @@ Maximum amount of characters per line (0 = disable) (Supported by JS Beautify, P
#### [CSV](#csv) #### [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**: **Description**:
@ -1870,7 +1870,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [EJS](#ejs) #### [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**: **Description**:
@ -2172,7 +2172,7 @@ Automatically beautify Elm files on save
#### [ERB](#erb) #### [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**: **Description**:
@ -2691,7 +2691,7 @@ Automatically beautify Go files on save
#### [Handlebars](#handlebars) #### [Handlebars](#handlebars)
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**: **Description**:
@ -2722,7 +2722,7 @@ Disable Handlebars Beautification
**Type**: `string` **Type**: `string`
**Enum**: `JS Beautify` **Enum**: `JS Beautify` `Pretty Diff`
**Description**: **Description**:
@ -2844,11 +2844,11 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be
**Type**: `string` **Type**: `string`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**: **Description**:
Indentation character (Supported by JS Beautify) Indentation character (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
@ -2922,11 +2922,11 @@ Indent <head> and <body> sections. (Supported by JS Beautify)
**Type**: `integer` **Type**: `integer`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**: **Description**:
Indentation size/length (Supported by JS Beautify) Indentation size/length (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
@ -2974,11 +2974,11 @@ Number of line-breaks to be preserved in one chunk (Supported by JS Beautify)
**Type**: `boolean` **Type**: `boolean`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**: **Description**:
Preserve line-breaks (Supported by JS Beautify) Preserve line-breaks (Supported by JS Beautify, Pretty Diff)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
@ -3118,11 +3118,11 @@ Indent wrapped attributes to after N characters (Supported by JS Beautify)
**Type**: `integer` **Type**: `integer`
**Supported Beautifiers**: [`JS Beautify`](#js-beautify) **Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff)
**Description**: **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** **Example `.jsbeautifyrc` Configuration**
@ -3199,7 +3199,7 @@ Automatically beautify Haskell files on save
#### [HTML](#html) #### [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**: **Description**:
@ -3644,7 +3644,7 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff)
#### [Jade](#jade) #### [Jade](#jade)
**Supported Beautifiers**: [`Pug Beautify`](#pug-beautify) [`Pug Beautify`](#pug-beautify) **Supported Beautifiers**: [`Pug Beautify`](#pug-beautify)
**Description**: **Description**:
@ -3846,7 +3846,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [JavaScript](#javascript) #### [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**: **Description**:
@ -4379,7 +4379,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
#### [JSON](#json) #### [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**: **Description**:
@ -4912,7 +4912,7 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre
#### [JSX](#jsx) #### [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**: **Description**:
@ -5393,7 +5393,7 @@ Remove trailing whitespace (Supported by Latex Beautify)
#### [LESS](#less) #### [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**: **Description**:
@ -5758,7 +5758,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Markdown](#markdown) #### [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**: **Description**:
@ -7461,7 +7461,7 @@ sort imports (requires isort installed) (Supported by autopep8)
#### [Riot.js](#riot.js) #### [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**: **Description**:
@ -7628,7 +7628,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [Ruby](#ruby) #### [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**: **Description**:
@ -7856,7 +7856,7 @@ Path to rustfmt program (Supported by rustfmt)
#### [Sass](#sass) #### [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**: **Description**:
@ -8221,7 +8221,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [SCSS](#scss) #### [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**: **Description**:
@ -8586,7 +8586,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Spacebars](#spacebars) #### [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**: **Description**:
@ -8898,7 +8898,7 @@ Change case of keywords (Supported by sqlformat)
#### [SVG](#svg) #### [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**: **Description**:
@ -9065,7 +9065,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [Swig](#swig) #### [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**: **Description**:
@ -9232,7 +9232,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [TSS](#tss) #### [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**: **Description**:
@ -9545,7 +9545,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Twig](#twig) #### [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**: **Description**:
@ -10404,7 +10404,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [Visualforce](#visualforce) #### [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**: **Description**:
@ -10571,7 +10571,7 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
#### [XML](#xml) #### [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**: **Description**:
@ -11016,7 +11016,7 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff)
#### [XTemplate](#xtemplate) #### [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**: **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", "name": "atom-beautify",
"main": "./src/beautify", "main": "./src/beautify",
"version": "0.29.2", "version": "0.29.4",
"private": true, "private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom", "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom",
"repository": { "repository": {
@ -88,7 +88,6 @@
"coffee-fmt": "0.11.0", "coffee-fmt": "0.11.0",
"coffee-formatter": "^0.1.2", "coffee-formatter": "^0.1.2",
"coffee-script": "^1.10.0", "coffee-script": "^1.10.0",
"cross-spawn": "^2.0.0",
"csscomb": "^3.1.7", "csscomb": "^3.1.7",
"diff": "^2.1.0", "diff": "^2.1.0",
"editorconfig": "^0.12.2", "editorconfig": "^0.12.2",
@ -117,6 +116,9 @@
"winston": "^1.0.0", "winston": "^1.0.0",
"yaml-front-matter": "^3.2.3" "yaml-front-matter": "^3.2.3"
}, },
"optionalDependencies": {
"cross-spawn": "^2.0.0"
},
"activationCommands": { "activationCommands": {
"atom-workspace": [ "atom-workspace": [
"atom-beautify:help-debug-editor", "atom-beautify:help-debug-editor",

View File

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

View File

@ -2,9 +2,14 @@ Promise = require("bluebird")
_ = require('lodash') _ = require('lodash')
fs = require("fs") fs = require("fs")
temp = require("temp").track() temp = require("temp").track()
spawn = require('cross-spawn')
readFile = Promise.promisify(fs.readFile) readFile = Promise.promisify(fs.readFile)
which = require('which') 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 module.exports = class Beautifier
@ -319,7 +324,7 @@ module.exports = class Beautifier
for key, method of @logger for key, method of @logger
# @verbose(key, method) # @verbose(key, method)
@[key] = method @[key] = method
@verbose("Beautifier logger has been initialized.") @verbose("#{@name} beautifier logger has been initialized.")
### ###
Constructor to setup beautifer Constructor to setup beautifer

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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