postcss-single-charset
Advanced tools
Comparing version 0.2.2 to 0.3.0
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 |
12
test.js
@@ -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"); |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
4698
67
107
2
1
+ Addedfs-extra@^0.14.0
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs-extra@0.14.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedncp@1.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedwrappy@1.0.2(transitive)
Updatedpostcss@^4.1.0