From 48f46e25b43e4ae40627baab8c1b8c5332b50f47 Mon Sep 17 00:00:00 2001 From: RealOrangeOne Date: Thu, 24 Mar 2016 19:47:00 +0000 Subject: [PATCH] Add basic transform plugin --- lib/default-options.json | 3 +++ lib/index.js | 11 +++++++++++ lib/transformer.js | 7 +++++++ package.json | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 lib/default-options.json create mode 100755 lib/index.js create mode 100644 lib/transformer.js diff --git a/lib/default-options.json b/lib/default-options.json new file mode 100644 index 0000000..015c9b8 --- /dev/null +++ b/lib/default-options.json @@ -0,0 +1,3 @@ +{ + "wrapWith": "call" +} diff --git a/lib/index.js b/lib/index.js new file mode 100755 index 0000000..a1bb0c1 --- /dev/null +++ b/lib/index.js @@ -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); +}); diff --git a/lib/transformer.js b/lib/transformer.js new file mode 100644 index 0000000..b0241fd --- /dev/null +++ b/lib/transformer.js @@ -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); +}; diff --git a/package.json b/package.json index 5133d0a..6b3407b 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "description": "", "main": "lib/index.js", "scripts": { + "test": "browserify ./test/test.js -t ./lib/index.js -o ./test/out.js", + "lint": "eslint 'lib/'" }, "author": "TheOrangeOne", "dependencies": {