gobem-proc-sqwish
Advanced tools
Comparing version 0.0.4 to 0.0.5
16
index.js
@@ -6,9 +6,11 @@ 'use strict'; | ||
module.exports = function () { | ||
let client, | ||
key = 'gobem-proc-sqwish'; | ||
module.exports = function (options) { | ||
options = options || {}; | ||
let client = options.redisClient, | ||
key = options.redisKey || 'gobem-proc-sqwish'; | ||
return { | ||
before: function (next) { | ||
client = redis.createClient(); | ||
client = client || redis.createClient(options.redisOptions); | ||
client.expire(key, 86400); | ||
@@ -18,3 +20,3 @@ next(); | ||
process: function (next, input, output, args, content, path) { | ||
process: function (next, input, output, config, content, path) { | ||
if (!content) return next(); | ||
@@ -28,3 +30,3 @@ client.hget(key, content, function (error, reply) { | ||
output.set(path, content); | ||
next(~args.indexOf('ignore-errors') ? null : error); | ||
next(options.ignoreErrors ? null : error); | ||
} | ||
@@ -39,3 +41,3 @@ } else { | ||
clear: function (next) { | ||
client.end(); | ||
options.redisClient && client.end(); | ||
next(); | ||
@@ -42,0 +44,0 @@ } |
{ | ||
"name": "gobem-proc-sqwish", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Processor to minify CSS files for gobem builder.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# gobem-proc-sqwish | ||
This processor for [gobem](https://github.com/Enet/gobem) minifies CSS files using **sqwish**. If an argument `ignore-errors` is passed and error occured, raw CSS will be written instead minified one. | ||
This processor for [gobem](https://github.com/Enet/gobem) minifies CSS files using **sqwish**. All options are passed as a single object. **gobem-proc-sqwish** requires redis database to cache results of the work. | ||
**gobem-proc-sqwish** requires redis database to cache results. | ||
The following options are supported: | ||
* `ignoreErrors`\ | ||
If this flag is `true` and error occured, raw file's content will be written instead minified one. | ||
* `redisKey`\ | ||
The key in the redis database to store cache. Default value is `gobem-proc-sqwish`. | ||
* `redisClient`\ | ||
Already created redis-client. [This](https://github.com/NodeRedis/node_redis) module is used. | ||
* `redisOptions`\ | ||
Options for a new redis-client. This field is ignored, if `redisClient` is passed. | ||
### Example for **build.gb** | ||
### Example for **build.js** | ||
```javascript | ||
select 0 ^components\/(\w+)\/\1\.css$ | ||
process gobem-proc-sqwish ignore-errors | ||
write 1 | ||
select 0 ^styles/[^.]\.css$ | ||
process gobem-proc-sqwish | ||
write 1 | ||
module.exports = function () { | ||
return [ | ||
['select', 0, /^components\/(\w+)\/\1\.css$/], | ||
['gobem-proc-sqwish', { | ||
ignoreErrors: true, | ||
redisOptions: { | ||
port: 6370 | ||
} | ||
}], | ||
['write', 1] | ||
]; // this array will be used as build instructions | ||
}; | ||
``` |
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
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
38282
5
36
29