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

broccoli-postcss

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-postcss - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

fixture/syntax-error.css

22

index.js

@@ -23,2 +23,3 @@ var path = require('path');

this.map = map || {};
this.warningStream = process.stderr;
}

@@ -50,23 +51,22 @@

processor.process(css, options)
var warningStream = this.warningStream;
return processor.process(css, options)
.then(function (result) {
result.warnings().forEach(function (warn) {
warningStream.write(warn.toString());
});
mkdirp.sync(path.dirname(toFilePath));
fs.writeFileSync(toFilePath, result.css);
})
.then(function (result) {
result.warnings().forEach(function (warn) {
process.stderr.write(warn.toString());
});
})
.catch(function (error) {
if ( 'CssSyntaxError' === error.name ) {
process.stderr.write(error.message + error.showSourceCode());
} else {
throw error;
error.message += "\n" + error.showSourceCode();
}
throw error;
});
};
module.exports = PostcssCompiler;
{
"name": "broccoli-postcss",
"version": "1.3.0",
"version": "1.3.1",
"description": "Postcss compiler for Broccoli",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,9 +6,20 @@ var assert = require('assert');

var postcssCompiler = require('./');
var pe = require('postcss-pseudoelements');
var postcss = require('postcss');
var plugins = [
var basicPluginSet = [
{
module: pe
module: require('postcss-pseudoelements')
}
];
var testWarnPluginSet = [
{
module: postcss.plugin('postcss-test-warn', function (opts) {
return function (css, result) {
result.warn("This is a warning.");
};
})
}
];
var map = {

@@ -19,9 +30,68 @@ inline: false,

var outputTree = postcssCompiler(['fixture'], 'fixture.css', 'output.css', plugins, map);
var warnings = [];
var warningStreamStub = {
write: function (warning) {
warnings.push(warning);
}
};
beforeEach(function () {
warnings = [];
});
it('should process css', function () {
var outputTree = postcssCompiler(['fixture'], 'fixture.css', 'output.css', basicPluginSet, map);
outputTree.warningStream = warningStreamStub;
return (new broccoli.Builder(outputTree)).build().then(function (dir) {
var content = fs.readFileSync(path.join(dir.directory, 'output.css'), 'utf8');
assert.strictEqual(content.trim(), 'a:before { content: "test"; }');
assert.deepEqual(warnings, []);
});
});
it('should expose warnings', function () {
var outputTree = postcssCompiler(['fixture'], 'warning.css', 'output.css', testWarnPluginSet, map);
outputTree.warningStream = warningStreamStub;
return (new broccoli.Builder(outputTree)).build().then(function (dir) {
var content = fs.readFileSync(path.join(dir.directory, 'output.css'), 'utf8');
assert.strictEqual(content.trim(), "a {}");
assert.deepEqual(warnings, [ "postcss-test-warn: This is a warning." ]);
});
});
it('should expose syntax errors', function () {
var outputTree = postcssCompiler(['fixture'], 'syntax-error.css', 'output.css', testWarnPluginSet, map);
outputTree.warningStream = warningStreamStub;
var count = 0;
return (new broccoli.Builder(outputTree)).build()
.catch(function (error) {
count++;
assert.strictEqual(error.name, "CssSyntaxError");
})
.then(function () {
assert.strictEqual(count, 1);
assert.deepEqual(warnings, []);
});
});
it('should expose non-syntax errors', function () {
var outputTree = postcssCompiler(['fixture'], 'missing-file.css', 'output.css', testWarnPluginSet, map);
outputTree.warningStream = warningStreamStub;
var count = 0;
return (new broccoli.Builder(outputTree)).build()
.catch(function () {
count++;
})
.then(function () {
assert.strictEqual(count, 1);
assert.deepEqual(warnings, []);
});
});
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