From 6fe5b91d93f6e6c60dae9c561ba851df1f9aedc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=BA?= Date: Sat, 27 May 2017 15:39:10 +0800 Subject: [PATCH 1/2] Inferring the syntax of unknow file --- .gitignore | 2 ++ README.md | 4 ++-- bin/cli.js | 10 +++++----- package.json | 6 +++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 93f1361..4d2f777 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules npm-debug.log +.nyc_output/ +coverage/ diff --git a/README.md b/README.md index 3b56dc4..d59735c 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,7 @@ $ cat input.css | stylefmt --stdin-filename input.css ```js var fs = require('fs'); var postcss = require('postcss'); -var scss = require('postcss-scss'); // when you use scss syntax +var syntax = require('postcss-html'); // when you use non-standard syntax var stylefmt = require('stylefmt'); var css = fs.readFileSync('input.css', 'utf-8'); @@ -311,7 +311,7 @@ postcss([ stylefmt ]).process(css, { from: 'input.css', - syntax: scss + syntax: syntax }) .then(function (result) { result.css; // formatted code diff --git a/bin/cli.js b/bin/cli.js index 1d34715..bfaf719 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -24,7 +24,7 @@ var argv = minimist(process.argv.slice(2), { }) var postcss = require('postcss') -var scss = require('postcss-scss') +var syntax = require('postcss-html') if (argv.v) { console.log(pkg.version) @@ -76,7 +76,7 @@ if (argv.r) { postcss([stylefmt(options)]) .process(css, { from: fullPath, - syntax: scss + syntax: syntax }) .then(function (result) { var formatted = result.css @@ -98,7 +98,7 @@ if (argv.r) { postcss([stylefmt(options)]) .process(css, { from: options.codeFilename, - syntax: scss + syntax: syntax }) .then(function (result) { process.stdout.write(result.css) @@ -122,7 +122,7 @@ function processMultipleFiles (files) { return postcss([stylefmt(options)]) .process(css, { from: fullPath, - syntax: scss + syntax: syntax }) .then(function (result) { var formatted = result.css @@ -156,7 +156,7 @@ function processMultipleFiles (files) { function isCss (filePath) { - return /^\.css|\.less|\.pcss|\.scss|\.wxss$/i.test(path.extname(filePath)) + return /^\.(?:vue|html?|(?:(?:[ps]?c)|le|wx|sa?)ss)$/i.test(path.extname(filePath)) } diff --git a/package.json b/package.json index 3888b31..395bc0c 100644 --- a/package.json +++ b/package.json @@ -37,12 +37,16 @@ "globby": "^6.1.0", "minimist": "^1.2.0", "postcss": "^6.0.1", + "postcss-html": "^0.3.0", + "postcss-less": "^1.0.0", + "postcss-sass": "^0.1.0", "postcss-scss": "^1.0.0", "postcss-sorting": "^2.1.0", "postcss-value-parser": "^3.3.0", "stdin": "^0.0.1", "stylelint": "^7.10.1", - "stylelint-order": "^0.4.4" + "stylelint-order": "^0.4.4", + "sugarss": "^1.0.0" }, "devDependencies": { "each-series": "^1.0.0", From 06b000910effa81911eb41f3ed1f4e2d2b5773c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=BA?= Date: Wed, 31 May 2017 16:32:15 +0800 Subject: [PATCH 2/2] update `postcss-html` --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 395bc0c..245c197 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "globby": "^6.1.0", "minimist": "^1.2.0", "postcss": "^6.0.1", - "postcss-html": "^0.3.0", - "postcss-less": "^1.0.0", + "postcss-html": "^0.4.0", + "postcss-less": "^1.0.1", "postcss-sass": "^0.1.0", "postcss-scss": "^1.0.0", "postcss-sorting": "^2.1.0",