Add basic transform plugin

This commit is contained in:
Jake Howard 2016-03-24 19:47:00 +00:00
parent 5ed4df7235
commit 48f46e25b4
4 changed files with 23 additions and 0 deletions

3
lib/default-options.json Normal file
View file

@ -0,0 +1,3 @@
{
"wrapWith": "call"
}

11
lib/index.js Executable file
View file

@ -0,0 +1,11 @@
var transformTools = require('browserify-transform-tools');
var transformer = require('./transformer');
const OPTIONS = {
excludeExtensions: ['.json']
};
module.exports = transformTools.makeStringTransform('jsfuckify', OPTIONS, function (content, transformOptions, done) {
const newContent = transformer(content, transformOptions.config);
done(null, newContent);
});

7
lib/transformer.js Normal file
View file

@ -0,0 +1,7 @@
var jscrewit = require('jscrewit');
var DEFAULT_OPTIONS = require('./default-options');
module.exports = function transformer(content, options) {
options = options || DEFAULT_OPTIONS;
return jscrewit.encode(content, options);
};

View file

@ -4,6 +4,8 @@
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
"test": "browserify ./test/test.js -t ./lib/index.js -o ./test/out.js",
"lint": "eslint 'lib/'"
}, },
"author": "TheOrangeOne", "author": "TheOrangeOne",
"dependencies": { "dependencies": {