Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalize-transforms

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-transforms - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

10

lib/css/less.js

@@ -6,3 +6,4 @@

var re = /.+\.less\.css/
var re_test = /\.less\.css/
var re_replace = /\.css[^\/]*/

@@ -14,3 +15,3 @@ module.exports = function (options) {

return function* transformLESS(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -22,3 +23,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.less/i)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'css'

@@ -46,1 +47,4 @@ var lesscss = yield* file.getString()

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -6,3 +6,4 @@

var re = /.+\.(sass|scss)\.css/
var re_test = /\.(sass|scss)\.css/
var re_replace = /\.css[^\/]*$/

@@ -14,3 +15,3 @@ module.exports = function (options) {

return function* transformSASS(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -22,3 +23,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.(sass|scss)/i)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'css'

@@ -51,1 +52,4 @@ var sasscss = yield* file.getString()

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -6,3 +6,4 @@

var re = /.+\.(styl|stylus)\.css/
var re_test = /\.(styl|stylus)\.css/
var re_replace = /\.css[^\/]*/

@@ -14,3 +15,3 @@ module.exports = function (options) {

return function* transformStylus(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -22,3 +23,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.(styl|stylus)/i)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'css'

@@ -46,1 +47,4 @@ var styluscss = yield* file.getString()

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -5,7 +5,6 @@

var compose = require('composition')
var Walker = require('normalize-walker')
var plugins = require('deps-walk').plugins
var deshebang = require('./js/deshebang')
module.exports = transform
var transforms = transform.transforms = []

@@ -18,3 +17,3 @@ fs.readdirSync(__dirname).forEach(function (type) {

name = name.replace(/\.js$/, '')
transform[name] = require('./' + type + '/' + name)
transforms.push(transform[name] = require('./' + type + '/' + name))
})

@@ -25,3 +24,2 @@ })

return compose([
deshebang,
transform.less(options),

@@ -36,9 +34,27 @@ transform.sass(options),

// before .js so that they can be required via js
Walker.plugins.css(options),
Walker.plugins.html(options),
plugins.css(options),
plugins.html(options),
transform.text(options), // after css for .css.js
transform.domify(options), // after text for .html.js
Walker.plugins.js(options),
Walker.plugins.file(options),
plugins.js(options),
plugins.file(options),
])
}
transform.map = function (uri) {
var prev
while (uri !== prev) uri = _map(prev = uri)
return uri
}
function _map(uri) {
for (var i = 0; i < transforms.length; i++) {
var transform = transforms[i]
var m = typeof transform.test === 'function'
? transform.test(uri)
: transform.test.exec(uri)
if (!m) continue
return uri.replace(transform.replace, '')
}
return uri
}

@@ -6,3 +6,4 @@

var re = /.+\.(coffee|litcoffee)\.js$/
var re_test = /\.(coffee|litcoffee)\.js$/
var re_replace = /\.js$/

@@ -14,3 +15,3 @@ module.exports = function (options) {

return function* transformCoffeeScript(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -22,3 +23,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.replace(/\.js$/, ''))
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'js'

@@ -48,1 +49,4 @@ var string = yield* file.getString()

}
module.exports.test = re_test
module.exports.replace = re_replace
var debug = require('debug')('normalize-transforms:domify')
var re = /.+\.html\.domify\.js$/
var re_test = /\.html\.domify\.js$/
var re_replace = /\.domify\.js$/

@@ -16,3 +17,3 @@ module.exports = function (options) {

return function* transformDomify(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -24,3 +25,3 @@ var file = this.file

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.html/)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))

@@ -37,1 +38,4 @@ var string = yield* file.getString()

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -8,3 +8,4 @@

var re = /.+\.jsx\.js$/
var re_test = /\.jsx\.js$/
var re_replace = /\.js$/

@@ -17,3 +18,3 @@ module.exports = function (options) {

return function* transformReact(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -25,3 +26,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.replace(/\.js$/, ''))
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'js'

@@ -46,1 +47,4 @@ file.string = transform(yield* file.getString(), options)

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -8,5 +8,4 @@

// can't figure out a way to combine these
var reHTML = /.+\.jade\.html/
var reJS = /.+\.jade(\.\w+)*\.js$/
var re_test = /\.jade\.(html|js$)/
var re_replace = /\.(html|js)[^\/]*$/

@@ -17,5 +16,5 @@ module.exports = function () {

return function* transformJade(next) {
var html = reHTML.test(this.basename)
var js = reJS.test(this.basename)
if (!html && !js) return yield* next
var m = re_test.exec(this.basename)
if (!m) return yield* next
var js = m[1] === 'js'

@@ -26,3 +25,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.jade/)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = 'jade'

@@ -32,8 +31,3 @@

if (html) {
file.string = jade.render(src, {
filename: file.source
})
file.type = 'html'
} else if (js) {
if (js) {
file.string = runtime

@@ -45,2 +39,7 @@ + 'export default '

file.type = 'js'
} else {
file.string = jade.render(src, {
filename: file.source
})
file.type = 'html'
}

@@ -50,3 +49,3 @@

if (!html && js) file.push(url)
if (js) file.push(url)
else if (!file.dependencies) file.dependencies = {}

@@ -68,1 +67,4 @@ }

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -6,7 +6,8 @@

var re = /json\.js$/i
var re_test = /json\.js$/
var re_replace = /\.js$/
module.exports = function () {
return function* walkJSON(next) {
if (!re.test(this.basename)) return yield* next
return function* transformJSON(next) {
if (!re_test.test(this.basename)) return yield* next

@@ -18,3 +19,3 @@ var file = this.file

file = this.setFile()
yield* file.setSource(file.uri.replace(/\.js$/, ''))
yield* file.setSource(file.uri.replace(re_replace, ''))
var string = yield* file.getString()

@@ -25,1 +26,4 @@ file.dependencies = {}

}
module.exports.test = re_test
module.exports.replace = re_replace

@@ -6,3 +6,4 @@

var re = /.+\.(md|markdown)\.html/i
var re_test = /\.(md|markdown)\.html/i
var re_replace = /\.html[^\/]*/

@@ -14,3 +15,3 @@ module.exports = function (options) {

return function* transformMarkdown(next) {
if (!re.test(this.basename)) return yield* next
if (!re_test.test(this.basename)) return yield* next

@@ -22,3 +23,3 @@ lazy()

debug(file.uri)
yield* file.setSource(file.uri.match(/^.*\.(md|markdown)/i)[0])
yield* file.setSource(file.uri.replace(re_replace, ''))
var string = yield* file.getString()

@@ -34,2 +35,5 @@ file.type = 'html'

module.exports.test = re_test
module.exports.replace = re_replace
function lazy() {

@@ -36,0 +40,0 @@ if (marked) return marked

@@ -9,15 +9,10 @@

var re = /\.(\w+)\.js$/i
var re_test = /\.(\w+)\.js$/i
var re_replace = /\.js$/
module.exports = function () {
return function* walkText(next) {
var m = re.exec(this.basename)
if (!m) return yield* next
return function* transformText(next) {
var ext = test(this.basename)
if (!ext) return yield* next
var ext = m[1]
// only support text/* mime types for now
// note: you need to manually add any custom mime types
// in the repo https://github.com/expressjs/mime-extended
if (!typeis(mime.lookup(ext), 'text/*')) return yield* next
// skip if already js or a different content type already

@@ -28,3 +23,3 @@ var file = this.file

var file = this.setFile()
yield* file.setSource(file.uri.replace(/\.js$/, ''))
yield* file.setSource(file.uri.replace(re_replace, ''))
file.type = ext

@@ -42,1 +37,12 @@

}
function test(basename) {
var m = re_test.exec(basename)
if (!m) return false
var ext = m[1]
if (typeis(mime.lookup(ext), 'text/*')) return ext
}
module.exports.test = test
module.exports.replace = re_replace
{
"name": "normalize-transforms",
"description": "Transforms for normalize-walker",
"version": "1.0.1",
"description": "Normalize's default transforms via deps-walk",
"version": "2.0.0",
"author": {

@@ -16,9 +16,9 @@ "name": "Jonathan Ong",

"type-is": "1",
"mime-types": "1",
"mime-types": "2",
"composition": "1",
"comment-shebang": "1",
"normalize-log": "1",
"normalize-walker": "1"
"deps-walk": "1"
},
"devDependencies": {
"esprima": "git://github.com/esnext/esprima#harmony-esnext",
"jade": "1",

@@ -25,0 +25,0 @@ "marked": "0",

# Walker Transforms
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![Gittip][gittip-image]][gittip-url]
For documentations, go to https://normalize.github.io/docs.html#transforms.
For documentation, go to https://normalize.github.io/api.html#transforms.
## Opting Out of Transforms
## Adding Transforms
Feel free to add transforms as long as they transform would be used
by a lot of people. In other words, don't add transform for your
by a lot of people. In other words, please don't add transform for your
brand new templating system.

@@ -29,14 +30,59 @@

## Forking
## Creating Custom Transforms
You might want to remove some transforms or add your own.
You might want to add your own transforms.
Feel free to fork this and use it as a replacement for `nlz(1)` or your app.
You may either fork and use your fork as a git dependency in your app:
[npm-image]: https://img.shields.io/npm/v/normalize-transforms.svg?style=flat
```js
{
"devDependencies": {
"nlz": "1",
"normalize-transforms": "jonathanong/transforms.js"
}
}
```
Or you may publish it as a separate package and reference it in your `.nlzrc`:
```js
{
"devDependencies": {
"nlz": "1",
"my-custom-transforms": "1"
}
}
```
`.nlzrc`:
```js
{
"transform": "my-custom-transforms"
}
```
When creating your own custom transform as your own package,
you don't have to fork this repository.
Instead, you can use this repository as a dependency
and bundle all the exported transforms like the exported `transform()` function: https://github.com/normalize/transforms.js/blob/master/lib/index.js
Caveat: if your transform function is a local file, prefix it with `./` so that
`nlz` knows that it's a local file. It will be resolved against `process.cwd()`.
[npm-image]: https://img.shields.io/npm/v/normalize-transforms.svg?style=flat-square
[npm-url]: https://npmjs.org/package/normalize-transforms
[travis-image]: https://img.shields.io/travis/normalize/transforms.js.svg?style=flat
[github-tag]: http://img.shields.io/github/tag/normalize/transforms.js.svg?style=flat-square
[github-url]: https://github.com/normalize/transforms.js/tags
[travis-image]: https://img.shields.io/travis/normalize/transforms.js.svg?style=flat-square
[travis-url]: https://travis-ci.org/normalize/transforms.js
[coveralls-image]: https://img.shields.io/coveralls/normalize/transforms.js.svg?style=flat
[coveralls-image]: https://img.shields.io/coveralls/normalize/transforms.js.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/normalize/transforms.js?branch=master
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat
[david-image]: http://img.shields.io/david/normalize/transforms.js.svg?style=flat-square
[david-url]: https://david-dm.org/normalize/transforms.js
[license-image]: http://img.shields.io/npm/l/normalize-transforms.svg?style=flat-square
[license-url]: LICENSE.md
[downloads-image]: http://img.shields.io/npm/dm/normalize-transforms.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/normalize-transforms
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
[gittip-url]: https://www.gittip.com/jonathanong/
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc