diff --git a/lib/format.js b/lib/format.js index f3b536c..9ff6b37 100644 --- a/lib/format.js +++ b/lib/format.js @@ -57,6 +57,12 @@ outputLines = res$; cleanLines = (onlyMatch ? compact : id)(outputLines); multiline = cleanLines.length > 1; + if (multiline && options.joinMultilines) { + cleanLines = [cleanLines.map(function(it){ + return it.trim(); + }).join(" ")]; + multiline = false; + } outputString = unlines(cleanLines); displayStartLine = node.loc.start.line; displayEndLine = node.loc.end.line; diff --git a/lib/options.js b/lib/options.js index 3403068..ec18f38 100644 --- a/lib/options.js +++ b/lib/options.js @@ -191,6 +191,11 @@ type: 'Boolean', description: 'JSON output for matches', longDescription: 'Prints out JSON for the output instead of formatted results. This will print out the node data as JSON, instead of the formatted text.' + }, { + option: 'join-multilines', + type: 'Boolean', + 'default': 'false', + description: 'join multiline results into one line (remove leading whitespaces and join by space)' }, { heading: 'Context control' }, { diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..fe9f537 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,749 @@ +{ + "name": "grasp", + "version": "0.6.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "dev": true + }, + "align-text": { + "version": "http://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "http://registry.npmjs.org/kind-of/-/kind-of-3.0.4.tgz", + "longest": "http://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "repeat-string": "http://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" + } + }, + "amdefine": { + "version": "http://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-regex": { + "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=" + }, + "argparse": { + "version": "http://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "integrity": "sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=", + "dev": true, + "requires": { + "sprintf-js": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz" + } + }, + "async": { + "version": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "balanced-match": { + "version": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=" + }, + "brace-expansion": { + "version": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz", + "integrity": "sha1-cZfX6qm4fmSDkOph/GbIRCdCDfk=", + "requires": { + "balanced-match": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", + "concat-map": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + } + }, + "camelcase": { + "version": "http://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "optional": true + }, + "center-align": { + "version": "http://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "optional": true, + "requires": { + "align-text": "http://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "lazy-cache": "http://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz" + } + }, + "cli-color": { + "version": "http://registry.npmjs.org/cli-color/-/cli-color-1.1.0.tgz", + "integrity": "sha1-3hiM3Ekp2DtnrqBBEPvtQP2/Z3U=", + "requires": { + "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "es6-iterator": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", + "memoizee": "http://registry.npmjs.org/memoizee/-/memoizee-0.3.10.tgz", + "timers-ext": "http://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz" + } + }, + "cliui": { + "version": "http://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "optional": true, + "requires": { + "center-align": "http://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "right-align": "http://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "wordwrap": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" + }, + "dependencies": { + "wordwrap": { + "version": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + } + } + }, + "commander": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", + "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=", + "dev": true + }, + "concat-map": { + "version": "http://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "d": { + "version": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "integrity": "sha1-2hhMU10Y2O57oqoim5FACfrhEwk=", + "requires": { + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + } + }, + "debug": { + "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + } + }, + "decamelize": { + "version": "http://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true, + "optional": true + }, + "deep-is": { + "version": "http://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, + "diff": { + "version": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", + "dev": true + }, + "es5-ext": { + "version": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "integrity": "sha1-qoRkHU23a2Krul5F/YBey6sUAEc=", + "requires": { + "es6-iterator": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", + "es6-symbol": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" + } + }, + "es6-iterator": { + "version": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", + "integrity": "sha1-vZaFZ9YWNeM8C4BydhPJy0sJa6w=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "es6-symbol": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" + } + }, + "es6-symbol": { + "version": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz", + "integrity": "sha1-lEgcZV56fK2C66gy2X1UM0ltf/o=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + } + }, + "es6-weak-map": { + "version": "http://registry.npmjs.org/es6-weak-map/-/es6-weak-map-0.1.4.tgz", + "integrity": "sha1-cGzvnpmqI2undmwjnIueKG6n0ig=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "es6-iterator": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz", + "es6-symbol": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" + }, + "dependencies": { + "es6-iterator": { + "version": "http://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz", + "integrity": "sha1-1vWLjE/EE8JJtLqhl2j45NfIlE4=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "es6-symbol": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" + } + }, + "es6-symbol": { + "version": "http://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz", + "integrity": "sha1-dhtcZ8/U8dGK+yNPaR1nhoLLO/M=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + } + } + } + }, + "escape-string-regexp": { + "version": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", + "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=", + "dev": true + }, + "escodegen": { + "version": "http://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "dev": true, + "requires": { + "esprima": "http://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "estraverse": "http://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "esutils": "http://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "optionator": "http://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "source-map": "http://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz" + } + }, + "esprima": { + "version": "http://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "estraverse": { + "version": "http://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "esutils": { + "version": "http://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "event-emitter": { + "version": "http://registry.npmjs.org/event-emitter/-/event-emitter-0.3.4.tgz", + "integrity": "sha1-jWPd+0z+H647MsomXExyAiIIC7U=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + } + }, + "flow-parser": { + "version": "0.62.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.62.0.tgz", + "integrity": "sha1-5Y0wAigVcEActQ7lzzkqUiUCAB8=" + }, + "glob": { + "version": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "http://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "inherits": "http://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "minimatch": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", + "once": "http://registry.npmjs.org/once/-/once-1.4.0.tgz", + "path-is-absolute": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + } + }, + "grasp-equery": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/grasp-equery/-/grasp-equery-0.4.0.tgz", + "integrity": "sha1-UBYynB7srP42cc7efJvA/JmxDXs=", + "requires": { + "flow-parser": "0.62.0", + "grasp-syntax-javascript": "0.2.2", + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" + } + }, + "grasp-squery": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/grasp-squery/-/grasp-squery-0.4.0.tgz", + "integrity": "sha1-BVk6foNuuoCjRl+WA/LDZqr1OX8=", + "requires": { + "grasp-syntax-javascript": "0.2.2", + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" + } + }, + "grasp-syntax-javascript": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/grasp-syntax-javascript/-/grasp-syntax-javascript-0.2.2.tgz", + "integrity": "sha1-Zg/9j/sesQj3dEdZSsN+crKzUEw=", + "requires": { + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" + } + }, + "growl": { + "version": "http://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "handlebars": { + "version": "http://registry.npmjs.org/handlebars/-/handlebars-4.0.6.tgz", + "integrity": "sha1-LORISFBTf5yXqAJtU5m5NcTtTtc=", + "dev": true, + "requires": { + "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "optimist": "0.6.1", + "source-map": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "uglify-js": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.7.4.tgz" + }, + "dependencies": { + "source-map": { + "version": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "http://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + } + } + } + }, + "has-flag": { + "version": "http://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "inflight": { + "version": "http://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "http://registry.npmjs.org/once/-/once-1.4.0.tgz", + "wrappy": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + } + }, + "inherits": { + "version": "http://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-buffer": { + "version": "http://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz", + "integrity": "sha1-z8hszV3FpS+oBIkRHGkgxFfi2Ys=", + "dev": true + }, + "isexe": { + "version": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz", + "integrity": "sha1-NvPiLmB1CSD15yQaR2qMakInWtA=", + "dev": true + }, + "istanbul": { + "version": "http://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "dev": true, + "requires": { + "abbrev": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "escodegen": "http://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "esprima": "http://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "glob": "http://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "handlebars": "http://registry.npmjs.org/handlebars/-/handlebars-4.0.6.tgz", + "js-yaml": "http://registry.npmjs.org/js-yaml/-/js-yaml-3.7.0.tgz", + "mkdirp": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "nopt": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "once": "http://registry.npmjs.org/once/-/once-1.4.0.tgz", + "resolve": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "which": "http://registry.npmjs.org/which/-/which-1.2.12.tgz", + "wordwrap": "http://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz" + }, + "dependencies": { + "wordwrap": { + "version": "http://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + } + } + }, + "jade": { + "version": "http://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", + "dev": true, + "requires": { + "commander": "http://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "mkdirp": "0.3.0" + }, + "dependencies": { + "commander": { + "version": "http://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", + "dev": true + }, + "mkdirp": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", + "dev": true + } + } + }, + "js-yaml": { + "version": "http://registry.npmjs.org/js-yaml/-/js-yaml-3.7.0.tgz", + "integrity": "sha1-XJZ93YN6m/3KXy3oQlOr6KHAO4A=", + "dev": true, + "requires": { + "argparse": "http://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", + "esprima": "http://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz" + } + }, + "kind-of": { + "version": "http://registry.npmjs.org/kind-of/-/kind-of-3.0.4.tgz", + "integrity": "sha1-e47PGKThf4Jp1ztQHJ8jLJaIenQ=", + "dev": true, + "requires": { + "is-buffer": "http://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz" + } + }, + "lazy-cache": { + "version": "http://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true, + "optional": true + }, + "levn": { + "version": "http://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "type-check": "http://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz" + }, + "dependencies": { + "type-check": { + "version": "http://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" + } + } + } + }, + "livescript": { + "version": "http://registry.npmjs.org/livescript/-/livescript-1.5.0.tgz", + "integrity": "sha1-T+cSHEEhfkYI4zTrnL4XYuY+VWY=", + "dev": true, + "requires": { + "optionator": "http://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "source-map": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" + }, + "dependencies": { + "source-map": { + "version": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "dev": true + } + } + }, + "longest": { + "version": "http://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "lru-cache": { + "version": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "lru-queue": { + "version": "http://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "requires": { + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + } + }, + "memoizee": { + "version": "http://registry.npmjs.org/memoizee/-/memoizee-0.3.10.tgz", + "integrity": "sha1-TsoNiu057J0Bf0xcLy9kMvQuXI8=", + "requires": { + "d": "http://registry.npmjs.org/d/-/d-0.1.1.tgz", + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "es6-weak-map": "http://registry.npmjs.org/es6-weak-map/-/es6-weak-map-0.1.4.tgz", + "event-emitter": "http://registry.npmjs.org/event-emitter/-/event-emitter-0.3.4.tgz", + "lru-queue": "http://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "next-tick": "http://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz", + "timers-ext": "http://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz" + } + }, + "minimatch": { + "version": "http://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", + "requires": { + "brace-expansion": "http://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" + } + }, + "minimist": { + "version": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "mkdirp": { + "version": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" + }, + "dependencies": { + "minimist": { + "version": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "mocha": { + "version": "http://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", + "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "dev": true, + "requires": { + "commander": "2.3.0", + "debug": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "diff": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "escape-string-regexp": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", + "glob": "http://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "growl": "http://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "jade": "http://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "mkdirp": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", + "to-iso-string": "http://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz" + }, + "dependencies": { + "glob": { + "version": "http://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "dev": true, + "requires": { + "inherits": "http://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "minimatch": "http://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz" + } + }, + "minimatch": { + "version": "http://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "dev": true, + "requires": { + "lru-cache": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "sigmund": "http://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" + } + }, + "supports-color": { + "version": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", + "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=", + "dev": true + } + } + }, + "ms": { + "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + }, + "next-tick": { + "version": "http://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz", + "integrity": "sha1-ddpKkn7liH45BliABltzNkE7MQ0=" + }, + "nopt": { + "version": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "http://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz" + } + }, + "once": { + "version": "http://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "wordwrap": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" + } + }, + "optionator": { + "version": "http://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "requires": { + "deep-is": "http://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "fast-levenshtein": "http://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.5.tgz", + "levn": "http://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "type-check": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "wordwrap": "http://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz" + }, + "dependencies": { + "fast-levenshtein": { + "version": "http://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.5.tgz", + "integrity": "sha1-vTMUV0RRmrHDbD7p8x8I6QebZ/I=" + }, + "type-check": { + "version": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz" + } + }, + "wordwrap": { + "version": "http://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + } + } + }, + "path-is-absolute": { + "version": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "prelude-ls": { + "version": "http://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, + "repeat-string": { + "version": "http://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "resolve": { + "version": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "right-align": { + "version": "http://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "optional": true, + "requires": { + "align-text": "http://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + } + }, + "sigmund": { + "version": "http://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=" + }, + "source-map": { + "version": "http://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": "http://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" + } + }, + "sprintf-js": { + "version": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "supports-color": { + "version": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "http://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" + } + }, + "timers-ext": { + "version": "http://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz", + "integrity": "sha1-ADRaLKkwidElEyIFQ4nSY+J7d+I=", + "requires": { + "es5-ext": "http://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", + "next-tick": "http://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz" + } + }, + "to-iso-string": { + "version": "http://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", + "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=", + "dev": true + }, + "uglify-js": { + "version": "http://registry.npmjs.org/uglify-js/-/uglify-js-2.7.4.tgz", + "integrity": "sha1-opWg3hK2plDAMcQN6w3ECxRWi9I=", + "dev": true, + "optional": true, + "requires": { + "async": "0.2.10", + "source-map": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "uglify-to-browserify": "1.0.2", + "yargs": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" + }, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", + "dev": true, + "optional": true + }, + "source-map": { + "version": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "dev": true, + "optional": true + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "which": { + "version": "http://registry.npmjs.org/which/-/which-1.2.12.tgz", + "integrity": "sha1-3me15FAmnxlJCe8j7OTr5Bb6EZI=", + "dev": true, + "requires": { + "isexe": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz" + } + }, + "window-size": { + "version": "http://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "http://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "http://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yargs": { + "version": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "http://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "cliui": "http://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "decamelize": "http://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "window-size": "http://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz" + } + } + } +} diff --git a/package.json b/package.json index 71b68b2..ac69d29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grasp", "author": "George Zahariev", - "version": "0.6.0", + "version": "0.6.0+gti", "homepage": "http://graspjs.com", "description": "JavaScript structural search, replace, and refactor", "keywords": [ diff --git a/package.json.ls b/package.json.ls index 6249aee..dc084d2 100644 --- a/package.json.ls +++ b/package.json.ls @@ -1,6 +1,6 @@ name: 'grasp' author: 'George Zahariev' -version: '0.6.0' +version: '0.6.0+gti' homepage: 'http://graspjs.com' description: 'JavaScript structural search, replace, and refactor' keywords: diff --git a/src/format.ls b/src/format.ls index 859a719..b03e2ca 100644 --- a/src/format.ls +++ b/src/format.ls @@ -40,6 +40,10 @@ function format-result name, input-lines, input-lines-length, {color, bold}, opt clean-lines = (if only-match then compact else id) output-lines multiline = clean-lines.length > 1 + if multiline and options.join-multilines + clean-lines = [clean-lines.map(-> it.trim()).join(" ")]; + multiline = false + output-string = unlines clean-lines display-start-line = node.loc.start.line diff --git a/src/options.ls b/src/options.ls index 9de5062..b76431f 100644 --- a/src/options.ls +++ b/src/options.ls @@ -182,7 +182,10 @@ options = type: 'Boolean' description: 'JSON output for matches' long-description: 'Prints out JSON for the output instead of formatted results. This will print out the node data as JSON, instead of the formatted text.' - + * option: 'join-multilines' + type: 'Boolean' + default: 'false' + description: 'join multiline results into one line (remove leading whitespaces and join by space)' * heading: 'Context control' * option: 'before-context' alias: 'B'