Skip to content

scrapjs/graspify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graspify Build Status Code Climate

Browserify transform to make source code replacements using grasp.

Installing

$ npm install --save-dev graspify

Usage

Define replacements in package.json:

{
  "main": "./index.js",
  "graspify": [
    ["equery", "__ + __", "{{.l}} - {{.r}}"],
    ["squery", "#myVar", "myVariable"]
  ],
  "dependencies": {
    "graspify": "^0.0.1"
  }
}

Run graspify transform:

$ browserify -t graspify index.js

Sometimes it is handy to perform global transform, to affect nested modules:

$ browserify -g graspify index.js.

API

Graspify can be used programmatically:

b.transform(graspify, replacements);

Pass replacements as a second optional argument. It will be merged with the ones defined in package.json.

var browserify = require('browserify');
var b = browserify('./entry.js');
var graspify = require('graspify');

b.transform(graspify, [
  ["squery", "#myVar", "myVariable"],
  ["equery", "__ + __", "{{.r}} + {{.l}}"],

  //you can also pass a replacement funtion
  ["equery", "require($module)", function(){
    return "require('stub')"
  }]
])

NPM

About

Browserify-transform using grasp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published