New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

compilers

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compilers - npm Package Compare versions

Comparing version
0.3.4
to
1.0.0
+4
test/fixtures/autoprefixer.js
module.exports = {
input: "a { display: flex; }",
output: "a { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; }"
};
module.exports = {
input: "body {\n background: white;\n}",
output: "body{background:#fff}"
};
module.exports = {
input: "test = (a) ->\n return a",
output: "(function() {\n var test;\n\n test = function(a) {\n return a;\n };\n\n}).call(this);\n"
};
module.exports = {
input: "body {\n background: white;\n}",
output: "body {\n background: white;\n}"
};
module.exports = {
input: "<div>{greeting}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "<div><%= greeting %></div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "var odds = evens.map(v => v + 1);",
output: "\"use strict\";\n\nvar odds = evens.map(function (v) {\n return v + 1;\n});"
};
module.exports = {
input: "%html\n %head\n %body\n .greeting Hello World",
output: "<html>\n<head></head>\n<body>\n<div class=\"greeting\">Hello World</div></body></html>"
};
module.exports = {
input: "<div>{{ greeting }}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "<div>{{ greeting }}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "<html>\n <head>\n </head>\n <body>\n <div>Hello World</div>\n </body>\n</html>",
output: "<html><head></head><body><div>Hello World</div></body></html>"
};
module.exports = {
input: "<html>\n <head>\n </head>\n <body>\n <div>Hello World</div>\n </body>\n</html>",
output: "<html>\n <head>\n </head>\n <body>\n <div>Hello World</div>\n </body>\n</html>"
};
module.exports = {
input: "html\n head\n body\n .greeting Hello World",
output: "<html><head></head><body><div class=\"greeting\">Hello World</div></body></html>"
};
module.exports = {
input: "function test(a) {\n return a;\n}",
output: "function test(a) {\n return a;\n}"
};
module.exports = {
input: "@color: white;\nbody {\n background: @color;\n}",
output: "body {\n background: white;\n}\n"
};
module.exports = {
input: "table =\n * id: 1\n name: 'george'",
output: "(function(){\n var table;\n table = {\n id: 1,\n name: 'george'\n };\n}).call(this);\n"
}
module.exports = {
input: "<div><%= greeting %></div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "<div>{{ greeting }}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "<div>{{ greeting }}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "var profile = <div>\n <img src=\"avatar.png\" className=\"profile\" />\n <h3>{[user.firstName, user.lastName].join(' ')}</h3>\n</div>;",
output: "var profile = React.createElement(\n \"div\",\n null,\n React.createElement(\"img\", { src: \"avatar.png\", className: \"profile\" }),\n React.createElement(\n \"h3\",\n null,\n [user.firstName, user.lastName].join(' ')\n )\n);"
};
module.exports = {
input: "$color: white;\nbody {\n background: $color;\n}",
output: "body {\n background: white; }\n"
};
module.exports = {
input: "body\n background\twhite",
output: "body {\n background: #fff;\n}\n"
};
module.exports = {
input: "macro swap { rule { ($x, $y) } => { var tmp = $y; $y = $x; $x = tmp; } }\nvar foo = 100; var bar = 200; swap (foo, bar)",
output: "var foo = 100;\nvar bar = 200;\nvar tmp = bar;\nbar = foo;\nfoo = tmp;"
}
module.exports = {
input: "<div>{{ greeting }}</div>",
output: "<div>Hello</div>"
};
module.exports = {
input: "class Greeter<T> {\n greeting: T;\n constructor(message: T) {\n this.greeting = message;\n }\n}",
output: "\"use strict\";\nvar Greeter = (function () {\n function Greeter(message) {\n this.greeting = message;\n }\n return Greeter;\n}());\n"
};
module.exports = {
input: "function test(a) {\n return a;\n}",
output: "function test(t){return t}"
};
module.exports = {
input: "<div><%= greeting %></div>",
output: "<div>Hello</div>"
};
var compilers = require("../"),
path = require("path"),
fs = require("fs"),
files = fs.readdirSync(path.join(__dirname, "fixtures"));
function test(file) {
var locals = { greeting: "Hello" },
name = file.replace(/\.js$/g, "");
describe(name, function() {
it("should compile correctly", function(next) {
var p = path.join(__dirname, "fixtures", file),
test = require(p),
compiler = compilers(name);
compiler(test.input, locals, function(err, compiled) {
try {
// Strip "generated by" as versions will change
compiled = compiled.replace(/\/\/[^\n\r]*generated by[^\n\r]*\n/gi, "");
compiled.should.equal(test.output);
next();
} catch (err) {
console.log(compiled);
next(err);
}
});
});
});
};
files.forEach(test);

Sorry, the diff of this file is not supported yet

+17
-9

@@ -79,5 +79,11 @@ /**

if (-1 === syntax.indexOf("next)"))
syntax = "try { next(null," + syntax + "); } catch (err) { next(err); }"
if (pipeline.suffix)
syntax = "try { next(null," + syntax + pipeline.suffix + "); } catch (err) { next(err); }"
else
syntax = "try { next(null," + syntax + "); } catch (err) { next(err); }"
else
if (pipeline.suffix)
syntax = syntax.replace("next", "function(err, compiled) { next(err, compiled" + pipeline.suffix + "); }")
cache[name] = createFunction(modules, syntax);
cache[name] = createFunction(modules, syntax, pipeline.options);

@@ -116,10 +122,12 @@ return cache[name];

// like "reorg", but we code manually given simplicity and desire for performance.
function createFunction(modules, syntax) {
var fn = new Function("modules", "str", "options", "next", syntax);
return function(str, options, next) {
if ("function" === typeof options) {
next = options;
options = {};
// `context` refers to local variables while `options` referes to compiler options
function createFunction(modules, syntax, options) {
var fn = new Function("modules", "str", "context", "options", "next", syntax);
options = options || {};
return function(str, context, next) {
if ("function" === typeof context) {
next = context;
context = {};
}
fn(modules, str, options, next);
fn(modules, str, context, options, next);
};

@@ -126,0 +134,0 @@ }

{
"name": "compilers",
"version": "0.3.4",
"version": "1.0.0",
"description": "Universal preprocessor loader for templating and transpiling",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -17,3 +17,35 @@ "author": "Brandon Carl",

"url": "git://github.com/brandoncarl/compilers.git"
},
"devDependencies": {
"autoprefixer": "^6.3.3",
"babel-core": "^6.5.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"clean-css": "^3.4.10",
"coffee-script": "^1.10.0",
"consolidate": "^0.14.0",
"dustjs-helpers": "^1.7.3",
"dustjs-linkedin": "^2.7.2",
"ejs": "^2.4.1",
"hamljs": "^0.6.2",
"handlebars": "^4.0.5",
"hogan.js": "^3.0.2",
"html-minifier": "^1.2.0",
"jade": "^1.11.0",
"less": "^2.6.0",
"livescript": "^1.4.0",
"lodash": "^4.5.1",
"mocha": "^2.4.5",
"mustache": "^2.2.1",
"node-sass": "^3.4.2",
"nunjucks": "^2.3.0",
"postcss": "^5.0.18",
"should": "^8.2.2",
"stylus": "^0.53.0",
"sweet.js": "^0.7.7",
"swig": "^1.4.2",
"typescript": "^1.8.2",
"uglify-js": "^2.6.2",
"underscore": "^1.8.3"
}
}

@@ -45,3 +45,3 @@ # compilers

callback to be fn(err, compiled). Defaults to `npm install` packages if they
are missing. To disable, set `options.fetch` to `false`;
are missing. To disable, set `context.fetch` to `false`;

@@ -53,3 +53,3 @@ Most packages are referenced by their npm name, common exceptions include:

**Returns**: <code>function</code> - Processor of format `fn(str, options, next)`
**Returns**: <code>function</code> - Processor of format `fn(str, context, next)`

@@ -59,3 +59,3 @@ | Param | Type | Description |

| name | <code>String</code> | Name of module (npm install name). |
| options | <code>Object</code> | Options include {fetch} and {dir} (install directory). |
| context | <code>Object</code> | Options include {fetch} and {dir} (install directory). |

@@ -65,3 +65,3 @@ **Example**

compilers("typescript")
// => fn(str, options, next) for typescript
// => fn(str, context, next) for typescript
```

@@ -101,2 +101,4 @@

| syntax | String | The function to be evaluated |
| options | Object | Optional options to be accessed via `options` |
| suffix | String | Optional suffix to call on results (sync or async) |

@@ -110,3 +112,3 @@ ### Example specification

"modules" : ["consolidate", "handlebars"],
"syntax" : "handlebars.render(str, options, next)"
"syntax" : "handlebars.render(str, context, next)"
}

@@ -124,3 +126,3 @@ ```

2. Replaces all `$x` with `modules[x]`. This allows incorporate of modules array.
3. Creates function that evaluates command. Note that `str`, `options` and `next`
3. Creates function that evaluates command. Note that `str`, `context` and `next`
have special meanings.

@@ -131,9 +133,9 @@

// Input
"handlebars.render(str, options, next)"
"handlebars.render(str, context, next)"
// Interim
modules[0].handlebars.render(str, options, next)
modules[0].handlebars.render(str, context, next)
// Equivalent function
function(str, options, next) { consolidate.handlebars.render(str, options, next); }
function(str, context, next) { consolidate.handlebars.render(str, context, next); }
```

@@ -140,0 +142,0 @@

@@ -28,3 +28,16 @@

"modules" : ["html-minifier"],
"syntax" : "minify(str)"
"syntax" : "minify(str, options)",
"options" : {
"removeComments": true,
"removeCommentsFromCDATA": true,
"removeCDATASectionsFromCDATA": true,
"collapseWhitespace": true,
"collapseBooleanAttributes": true,
"removeAttributeQuotes": true,
"removeRedundantAttributes": true,
"useShortDoctype": true,
"removeEmptyAttributes": true,
"minifyJS": true,
"minifyCSS": true
}
},

@@ -35,5 +48,6 @@ {

"type" : "js",
"modules" : ["babel", "babel-preset-es2015"],
"modules" : ["babel-core", "babel-preset-es2015"],
"syntax" : "transform(str, options)",
"options" : { "presets" : ["es2015"] }
"options" : { "presets" : ["es2015"] },
"suffix" : ".code"
},

@@ -44,5 +58,6 @@ {

"type" : "js",
"modules" : ["babel", "babel-preset-react"],
"modules" : ["babel-core", "babel-preset-react"],
"syntax" : "transform(str, options)",
"options" : { "presets" : ["react"] }
"options" : { "presets" : ["react"] },
"suffix" : ".code"
},

@@ -68,3 +83,3 @@ {

"modules" : ["stylus"],
"syntax" : "render(str, options, next)"
"syntax" : "render(str, context, next)"
},

@@ -76,3 +91,3 @@ {

"modules" : ["consolidate", "ejs"],
"syntax" : "ejs.render(str, options, next)"
"syntax" : "ejs.render(str, context, next)"
},

@@ -91,3 +106,7 @@ {

"modules" : ["sweet.js"],
"syntax" : "compile(str)"
"syntax" : "compile(str, options)",
"options" : {
readableNames : true
},
"suffix" : ".code"
},

@@ -99,3 +118,3 @@ {

"modules" : ["consolidate", "handlebars"],
"syntax" : "handlebars.render(str, options, next)"
"syntax" : "handlebars.render(str, context, next)"
},

@@ -107,3 +126,3 @@ {

"modules" : ["consolidate", "swig"],
"syntax" : "swig.render(str, options, next)"
"syntax" : "swig.render(str, { locals : context }, next)",
},

@@ -115,3 +134,3 @@ {

"modules" : ["consolidate", "mustache"],
"syntax" : "mustache.render(str, options, next)"
"syntax" : "mustache.render(str, context, next)"
},

@@ -122,4 +141,4 @@ {

"type" : "html",
"modules" : ["consolidate", "dustjs-linkedin", "dust-helpers"],
"syntax" : "dust.render(str, options, next)"
"modules" : ["consolidate", "dustjs-linkedin", "dustjs-helpers"],
"syntax" : "dust.render(str, context, next)"
},

@@ -131,3 +150,3 @@ {

"modules" : ["consolidate", "hamljs"],
"syntax" : "haml.render(str, options, next)"
"syntax" : "haml.render(str, context, next)"
},

@@ -139,17 +158,10 @@ {

"modules" : ["consolidate", "nunjucks"],
"syntax" : "nunjucks.render(str, options, next)"
"syntax" : "nunjucks.render(str, context, next)"
},
{
"name" : "swig",
"ext" : "html",
"type" : "html",
"modules" : ["consolidate", "swig"],
"syntax" : "swig.render(str, options, next)"
},
{
"name" : "hogan",
"ext" : "html",
"type" : "html",
"modules" : ["consolidate", "hogan"],
"syntax" : "hogan.render(str, options, next)"
"modules" : ["consolidate", "hogan.js"],
"syntax" : "hogan.render(str, context, next)"
},

@@ -161,3 +173,3 @@ {

"modules" : ["consolidate", "jade"],
"syntax" : "jade.render(str, options, next)"
"syntax" : "jade.render(str, context, next)"
},

@@ -169,3 +181,4 @@ {

"modules" : ["node-sass"],
"syntax" : "renderSync({ \"data\" : str })"
"syntax" : "render({ \"data\" : str }, next)",
"suffix" : ".css.toString()"
},

@@ -177,3 +190,4 @@ {

"modules" : ["less"],
"syntax" : "render(str, options, next)"
"syntax" : "render(str, options, next)",
"suffix" : ".css"
},

@@ -192,3 +206,3 @@ {

"modules" : ["consolidate", "lodash"],
"syntax" : "['lodash'].render(str, options, next)"
"syntax" : "['lodash'].render(str, context, next)"
},

@@ -200,3 +214,3 @@ {

"modules" : ["consolidate", "underscore"],
"syntax" : "['underscore'].render(str, options, next)"
"syntax" : "['underscore'].render(str, context, next)"
},

@@ -208,3 +222,4 @@ {

"modules" : ["uglify-js"],
"syntax" : "minify(str, { \"fromString\" : true}).code"
"syntax" : "minify(str, { \"fromString\" : true })",
"suffix" : ".code"
},

@@ -211,0 +226,0 @@ {