Grasp 0.2.0 has been released!
Grasp is a command line utility that allows you to search and replace your JavaScript code - but unlike programs such as grep
or sed
it searches the structure behind your code (the abstract syntax tree), rather than simply the text you’ve written - this allows you to:
- Search your code with unparalleled power
- Quickly and easily refactor your code
- Implement basic macros in a single line
This version fixes some bugs and adds new features which really make it easy to refactor your code using Grasp.
Install with npm install -g grasp
(or see install page).
Update with npm update -g grasp
.
I’m also happy to announce that a Sublime Text plugin has been developed for Grasp: sublime-grasp by joneshf. This has been added to the new tools section of the site. To any vi, Emacs, or other text editor/IDE plugin developers: create a plugin for Grasp and be featured in the next release post and in the tools section!
Check out the main site, the demo, the quick start guide, and the documentation!
Questions? Comments? Join #graspjs
on Freenode and talk to gkz
or post an issue in the GitHub issues section.
Changes
- Added support for named wildcards in equery, both single and array types -
$name
and_$name
- Added filters feature for use during replacement
- Added an
input
option tograsp
when used as a library - this allows you to specify the input you want to search/replace as a string - Added two helper functions,
grasp.search
andgrasp.replace
, when using Grasp as a library - Allowed searching for expression statements in equery when explicitly using a semicolon
;
- Created an object varient of each of the wildcards in equery - eg.
_:_
,$:name
,_:$
,_:$name
- Removed
@attribute
squery syntax, simply use*.attribute
instead - Fixed issue #4 - Bug when replacing overlapping matches
- Fixed issue #5 - First level of quotes in replacements ignored
- Fixed issue #6 - Absolute paths are not supported on the command line
- Fixed an issue with getting the raw value of operators
Migrating from 0.1.0
- Change any use of the squery
@attribute
to*.attribute
. Eg.@left
should become*.left
. - Change any equery bitwise OR (
|
) searches to not be spaced, so they are not confused with the new filter syntax. Eg.x | y
should becomex|y
.