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

postcss-single-charset

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-single-charset - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

.eslintrc

14

index.js

@@ -1,13 +0,9 @@

'use strict';
"use strict";
var postcss = require('postcss');
var postcss = require("postcss");
module.exports = function () {
module.exports = postcss.plugin("single-charset", function () {
return function (css) {
var metCharset = false;
css.eachAtRule(function (atRule) {
if (atRule.name !== 'charset') {
return;
}
css.eachAtRule("charset", function (atRule) {
if (!metCharset) {

@@ -21,2 +17,2 @@ metCharset = true;

};
};
});
{
"name": "postcss-single-charset",
"description": "Pop first @charset rule in CSS file.",
"version": "0.2.2",
"version": "0.3.0",
"author": "Kyo Nagashima <hail2u@gmail.com> (https://kyonagashima.com/)",

@@ -10,9 +10,10 @@ "bugs": {

"dependencies": {
"postcss": "^4.0.0"
"fs-extra": "^0.14.0",
"postcss": "^4.1.0"
},
"homepage": "https://github.com/hail2u/postcss-single-charset",
"keywords": [
"postcss",
"charset",
"css",
"charset"
"postcss-plugin"
],

@@ -19,0 +20,0 @@ "license": {

@@ -7,2 +7,41 @@ postcss-single-charset

SYNOPSIS
--------
Sometimes concatenated CSS file has `@charset` directive in the middle or has
many `@charset` directives:
.foo {
color: red;
}
@charset "Shift_JIS";
.bar {
color: green;
}
@charset "Shift_JIS";
.baz {
color: blue;
}
This PostCSS plugin fixes these invalid `@charset` like this:
@charset "Shift_JIS";
.foo {
color: red;
}
.bar {
color: green;
}
.baz {
color: blue;
}
INSTALL

@@ -17,10 +56,11 @@ -------

var fs = require('fs');
var postcss = require('postcss');
var fs = require("fs");
var postcss = require("postcss");
var input = fs.readFileSync('input.css', 'utf8');
var output = postcss().use(
require('postcss-single-charset')()
).process(input).css;
fs.writeFileSync('output.css', output);
var css = fs.readFileSync("input.css", "utf8");
postcss([
require("postcss-single-charset")()
]).process(css).then(function (result) {
fs.writeFileSync("output.css", result.css);
});

@@ -32,3 +72,3 @@

grunt.loadNpmTasks('postcss-single-charset');
grunt.loadNpmTasks("postcss-single-charset");

@@ -38,6 +78,6 @@ And configure like that:

grunt.initConfig({
single_charset: {
singleCharset: {
basic: {
files: {
'dest/basic.css': ['src/basic.css']
"dest/basic.css": ["src/basic.css"]
}

@@ -54,3 +94,3 @@ },

files: {
'dest/with_options.css': ['src/with_options.css']
"dest/with_options.css": ["src/with_options.css"]
}

@@ -71,2 +111,2 @@ }

[1]: https://github.com/postcss/postcss#source-map-1
[1]: https://github.com/postcss/postcss#source-map

@@ -1,5 +0,5 @@

'use strict';
"use strict";
var assert = require('assert');
var postcss = require('postcss');
var assert = require("assert");
var postcss = require("postcss");

@@ -9,5 +9,5 @@ var fixture = '.foo{color:red;}@charset "UTF-8";.bar{color:green;}@charset "EUC-JP";.baz{color:blue}';

var actual = postcss().use(require('./index')()).process(fixture).css;
assert.strictEqual(actual, expected, 'should pop @charset.');
var actual = postcss().use(require("./index")()).process(fixture).css;
assert.strictEqual(actual, expected, "should pop @charset.");
console.log('Ok');
console.log("Ok");
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