Skip to content

Commit

Permalink
Merge pull request #46 from zgreen/v3.0.5
Browse files Browse the repository at this point in the history
V3.0.5
  • Loading branch information
zgreen authored Sep 15, 2019
2 parents 7320765 + b4a49e5 commit a4dd7da
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 59 deletions.
Empty file modified lib/atRule.js
100644 → 100755
Empty file.
Empty file modified lib/getChildRules.js
100644 → 100755
Empty file.
Empty file modified lib/getCriticalDestination.js
100644 → 100755
Empty file.
Empty file modified lib/getCriticalRules.js
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ var _cssnano = require('cssnano');

var _cssnano2 = _interopRequireDefault(_cssnano);

var _fs = require('fs');
var _fsExtra = require('fs-extra');

var _fs2 = _interopRequireDefault(_fs);
var _fsExtra2 = _interopRequireDefault(_fsExtra);

var _path = require('path');

Expand Down Expand Up @@ -134,7 +134,7 @@ function hasNoOtherChildNodes() {
* @param {string} css CSS to write to file.
*/
function writeCriticalFile(filePath, css) {
_fs2.default.writeFile(filePath, css, { flag: append ? 'a' : 'w' }, function (err) {
_fsExtra2.default.outputFile(filePath, css, { flag: append ? 'a' : 'w' }, function (err) {
append = true;
if (err) {
console.error(err);
Expand Down
Empty file modified lib/matchChild.js
100644 → 100755
Empty file.
135 changes: 90 additions & 45 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-critical-css",
"version": "3.0.4",
"version": "3.0.5",
"description": "Generate critical CSS using PostCSS",
"main": "index.js",
"repository": {
Expand All @@ -27,13 +27,13 @@
"eslint": "^3.3.1",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^4.2.3",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"flow-bin": "^0.100.0",
"minimist": "^1.2.0",
"tape": "^4.10.2"
"tape": "^4.11.0"
},
"scripts": {
"build": "eslint src/** && npm run flow && babel src --out-dir lib",
Expand All @@ -53,6 +53,7 @@
"dependencies": {
"chalk": "^1.1.3",
"cssnano": "^4.1.10",
"postcss": "^7.0.17"
"fs-extra": "^8.1.0",
"postcss": "^7.0.18"
}
}
Empty file modified src/atRule.js
100644 → 100755
Empty file.
Empty file modified src/getChildRules.js
100644 → 100755
Empty file.
Empty file modified src/getCriticalDestination.js
100644 → 100755
Empty file.
Empty file modified src/getCriticalRules.js
100644 → 100755
Empty file.
13 changes: 6 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { green, yellow } from 'chalk'
import postcss from 'postcss'
import cssnano from 'cssnano'
import fs from 'fs'
import fs from 'fs-extra'
import path from 'path'
import { getCriticalRules } from './getCriticalRules'

Expand Down Expand Up @@ -94,9 +94,8 @@ function dryRunOrWriteFile (
result: Object
): Promise<any> {
const { css } = result
return new Promise(
(resolve: Function): void =>
resolve(dryRun ? doDryRun(css) : writeCriticalFile(filePath, css))
return new Promise((resolve: Function): void =>
resolve(dryRun ? doDryRun(css) : writeCriticalFile(filePath, css))
)
}

Expand All @@ -121,7 +120,7 @@ function hasNoOtherChildNodes (
* @param {string} css CSS to write to file.
*/
function writeCriticalFile (filePath: string, css: string) {
fs.writeFile(
fs.outputFile(
filePath,
css,
{ flag: append ? 'a' : 'w' },
Expand Down Expand Up @@ -165,8 +164,8 @@ function buildCritical (options: Object = {}): Function {
(init: Object, cur: string): Function => {
const criticalCSS = postcss.root()
const filePath = path.join(outputPath, cur)
criticalOutput[cur].each(
(rule: Object): Function => criticalCSS.append(rule.clone())
criticalOutput[cur].each((rule: Object): Function =>
criticalCSS.append(rule.clone())
)
return (
postcss(minify ? [cssnano] : [])
Expand Down
Empty file modified src/matchChild.js
100644 → 100755
Empty file.

0 comments on commit a4dd7da

Please sign in to comment.