Comparing version 7.1.0 to 7.2.0
18
index.js
@@ -67,3 +67,3 @@ const cssPrefix = require('postcss-prefix') | ||
applyTransforms(filename, String(src), xtend(options), function (err, css) { | ||
applyTransforms(filename, String(src), xtend(options), function (err, result) { | ||
if (err) return done(err) | ||
@@ -74,5 +74,5 @@ var p = postcss() | ||
try { | ||
css = p.process(css).toString() | ||
result.css = p.process(result.css).toString() | ||
return done(null, css, prefix) | ||
return done(null, result, prefix) | ||
} catch (e) { | ||
@@ -87,5 +87,6 @@ return done(e) | ||
function applyTransforms (filename, src, options, done) { | ||
var current = { css: src, files: [] } | ||
mapLimit(options.transform, 1, iterate, function (err) { | ||
if (err) return done(err) | ||
done(null, src) | ||
done(null, current) | ||
}) | ||
@@ -112,5 +113,10 @@ | ||
const transform = require(transformPath) | ||
transform(filename, src, opts, function (err, result) { | ||
transform(filename, current.css, opts, function (err, result) { | ||
if (err) return next(err) | ||
src = result | ||
if (typeof result === 'string') { | ||
current.css = result | ||
} else { | ||
current.css = result.css | ||
current.files = current.files.concat(result.files) | ||
} | ||
next() | ||
@@ -117,0 +123,0 @@ }) |
{ | ||
"name": "sheetify", | ||
"version": "7.1.0", | ||
"version": "7.2.0", | ||
"description": "Modular CSS bundler", | ||
@@ -5,0 +5,0 @@ "repository": "stackcss/sheetify", |
@@ -58,2 +58,37 @@ const browserify = require('browserify') | ||
}) | ||
t.test('should emit \'file\' events if transform included more files', function (t) { | ||
const bpath = path.join(__dirname, 'fixtures/plugins-source.js') | ||
const bOpts = { browserField: false } | ||
const expectedFiles = [ | ||
bpath, | ||
'/path/to/included/file.css' | ||
] | ||
const actualFiles = [] | ||
browserify(bpath, bOpts) | ||
.transform(sheetify, { | ||
transform: [ | ||
[ require.resolve('./fixtures/files-plugin'), { | ||
file: '/path/to/included/file.css' | ||
} ] | ||
] | ||
}) | ||
.exclude('sheetify/insert') | ||
.on('file', onfile) | ||
.on('transform', ontransform) | ||
.bundle(function (err, result) { | ||
t.ifError(err) | ||
t.deepEqual(actualFiles.sort(), expectedFiles.sort()) | ||
t.end() | ||
}) | ||
function onfile (filename) { | ||
if (actualFiles.indexOf(filename) === -1) { | ||
actualFiles.push(filename) | ||
} | ||
} | ||
function ontransform (tr) { | ||
tr.on('file', onfile) | ||
} | ||
}) | ||
}) |
@@ -205,6 +205,6 @@ const cssResolve = require('style-resolve').sync | ||
function handleCss (val) { | ||
sheetify(val.css, val.filename, val.opts, function (err, css, prefix) { | ||
sheetify(val.css, val.filename, val.opts, function (err, result, prefix) { | ||
if (err) return done(err) | ||
const str = [ | ||
"((require('sheetify/insert')(" + JSON.stringify(css) + ')', | ||
"((require('sheetify/insert')(" + JSON.stringify(result.css) + ')', | ||
' || true) && ' + JSON.stringify(prefix) + ')' | ||
@@ -219,2 +219,7 @@ ].join('') | ||
val.node.update(lolSemicolon + str) | ||
result.files.forEach(function (includedFile) { | ||
transformStream.emit('file', includedFile) | ||
}) | ||
done() | ||
@@ -221,0 +226,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
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
36494
36
805