transformers
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -0,1 +1,8 @@ | ||
## 1.7.0 - 2013-01-30 | ||
- **component-js** | ||
- **component-css** | ||
- **html2jade** - must be `v0.0.7` because of a bug in later versions | ||
- Much more extensive tests | ||
## 1.6.0 - 2013-01-29 | ||
@@ -2,0 +9,0 @@ |
@@ -461,2 +461,48 @@ var dirname = require('path').dirname; | ||
exports.component = exports['component-js'] = new Transformer({ | ||
name: 'component-js', | ||
engines: ['component-builder'], | ||
outputFormat: 'js', | ||
async: function (str, options, cb) { | ||
if (this.cache(options)) return this.cache(options); | ||
var self = this; | ||
var builder = new this.engine(dirname(options.filename)); | ||
if (options.development) { | ||
builder.development(); | ||
} | ||
builder.build(function (err, obj) { | ||
if (err) return cb(err); | ||
else return cb(null, self.cache(options, obj.require + obj.js)); | ||
}); | ||
} | ||
}); | ||
exports['component-css'] = new Transformer({ | ||
name: 'component-css', | ||
engines: ['component-builder'], | ||
outputFormat: 'css', | ||
async: function (str, options, cb) { | ||
if (this.cache(options)) return this.cache(options); | ||
var self = this; | ||
var builder = new this.engine(dirname(options.filename)); | ||
if (options.development) { | ||
builder.development(); | ||
} | ||
builder.build(function (err, obj) { | ||
if (err) return cb(err); | ||
else return cb(null, self.cache(options, obj.css)); | ||
}); | ||
} | ||
}); | ||
exports['html2jade'] = new Transformer({ | ||
name: 'html2jade', | ||
engines: ['html2jade'], | ||
outputFormat: 'jade', | ||
async: function (str, options, cb) { | ||
this.engine.convertHtml(str, options, cb); | ||
} | ||
}); | ||
/** | ||
@@ -463,0 +509,0 @@ * Marker transformers (they don't actually apply a transformation, but let you declare the 'outputFormat') |
{ | ||
"name": "transformers", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "String/Data transformations for use in templating libraries, static site generators and web frameworks", | ||
@@ -63,3 +63,5 @@ "main": "lib/transformers.js", | ||
"dot": "*", | ||
"css": "*" | ||
"css": "*", | ||
"component-builder": "*", | ||
"html2jade": "0.0.7" | ||
}, | ||
@@ -66,0 +68,0 @@ "dependencies": { |
@@ -54,2 +54,5 @@ # transformers | ||
- markdown - You can use `marked`, `supermarked`, `markdown-js` or `markdown` | ||
- [component-js](http://documentup.com/component/component) [(website)](http://component.io) - `npm install component-builder` options: `{development: false}` | ||
- [component-css](http://documentup.com/component/component) [(website)](http://component.io) - `npm install component-builder` options: `{development: false}` | ||
- [html2jade](http://documentup.com/donpark/html2jade) [(website)](http://html2jade.aaron-powell.com/) - `npm install html2jade@0.0.7` note that later versions have a bug that means they won't work (this will be fixed by [pull/48](https://github.com/donpark/html2jade/pull/48)) | ||
@@ -56,0 +59,0 @@ Pull requests to add more transforms will always be accepted providing they are open-source, come with unit tests, and don't cause any of the tests to fail. |
@@ -6,3 +6,3 @@ var transformers = require('../'); | ||
fs.readdirSync(path.join(__dirname, 'transformers')) | ||
fs.readdirSync(path.join(__dirname, 'simple')) | ||
.forEach(function (transformer) { | ||
@@ -14,3 +14,3 @@ if (!transformers[transformer]) { | ||
function locate(name) { | ||
return path.join(__dirname, 'transformers', transformer.name, name + '.txt'); | ||
return path.join(__dirname, 'simple', transformer.name, name + '.txt'); | ||
} | ||
@@ -72,2 +72,55 @@ function read(name) { | ||
}); | ||
}); | ||
}); | ||
function read(name) { | ||
try { | ||
return fs.readFileSync(locate(name)).toString(); | ||
} catch (ex) { | ||
return null; | ||
} | ||
} | ||
describe('uglify-js', function () { | ||
var str = fs.readFileSync(path.join(__dirname, 'fixtures', 'uglify-js', 'script.js')).toString(); | ||
it('minifies files', function () { | ||
var res = transformers['uglify-js'].renderSync(str, {}); | ||
expect(res.length).to.be.lessThan(82); | ||
expect(require('vm').runInNewContext(res)).to.be('Hello Forbes Lindesay!'); | ||
}); | ||
it('beautifies files with {mangle: false, compress: false, output: {beautify: true}}', function () { | ||
var res = transformers['uglify-js'].renderSync(str, {mangle: false, compress: false, output: {beautify: true}}); | ||
expect(res).to.be('(function(name) {\n function hello(world) {\n return "Hello " + world + "!";\n }\n return hello(name);\n})("Forbes Lindesay");'); | ||
expect(require('vm').runInNewContext(res)).to.be('Hello Forbes Lindesay!'); | ||
}); | ||
}); | ||
describe('component', function () { | ||
var p = path.join(__dirname, 'fixtures', 'component', 'component.json'); | ||
var output = path.join(__dirname, 'fixtures', 'component', 'build'); | ||
function simplifyCSS(str) { | ||
return transformers['uglify-css'].renderSync(str); | ||
} | ||
describe('component-js', function () { | ||
it('builds the JavaScript file', function (done) { | ||
transformers['component-js'].renderFile(p, {}, function (err, res) { | ||
if (err) return done(err); | ||
expect(require('vm').runInNewContext(res + '\nrequire("foo")')).to.be('foo'); | ||
done(); | ||
}) | ||
}); | ||
}); | ||
describe('component-css', function () { | ||
it('builds the CSS file', function (done) { | ||
transformers['component-css'].renderFile(p, {}, function (err, res) { | ||
if (err) return done(err); | ||
expect(simplifyCSS(res)).to.be("#foo{name:'bar'}#baz{name:'bing'}"); | ||
done(); | ||
}) | ||
}); | ||
}); | ||
}); |
@@ -7,4 +7,5 @@ var transformers = require('../'); | ||
.forEach(function (engine) { | ||
if (engine != '.') | ||
if (engine != '.' && !pack.devDependencies[engine]) { | ||
pack.devDependencies[engine] = '*'; | ||
} | ||
}); | ||
@@ -11,0 +12,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45975
113
921
129
44
12