Skip to content
Permalink
Browse files

fix: run after plugins against files serially (#508)

Also ES6-ified including `class`.

BREAKING CHANGE: `Processor` instances must be instantiated with `new`, they're no longer auto-instantiating
  • Loading branch information...
tivac committed Aug 25, 2018
1 parent e32a4b3 commit 14bae1d8935202c702439349c899c583bcd66f02

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -11,6 +11,7 @@
"scripts": {
"cover": "jest --coverage",
"lint": "eslint .",
"outdated": "lerna exec --no-bail --stream -- npm outdated",
"parser": "pegjs packages/core/parsers/parser.pegjs",
"prerelease": "npm test -- --ci",
"release": "lerna publish",
@@ -23,26 +24,25 @@
"@tivac/eslint-config": "2.2.1",
"browserify": "16.2.2",
"cli-tester": "2.0.0",
"cssnano": "4.0.5",
"dedent": "0.7.0",
"dentist": "1.0.3",
"eslint": "5.4.0",
"eslint-plugin-jest": "21.21.0",
"eslint-plugin-jest": "^21.22.0",
"factor-bundle": "2.5.0",
"from2-string": "1.1.0",
"jest": "23.5.0",
"jest-cli": "23.5.0",
"lerna": "3.1.2",
"www": "file:packages/www",
"lerna": "^3.1.4",
"pegjs": "0.10.0",
"read-dir-deep": "1.0.4",
"rollup": "0.64.1",
"rollup-plugin-svelte": "4.2.1",
"shelljs": "0.8.2",
"svelte": "2.11.0",
"svelte": "^2.13.0",
"test-utils": "file:packages/test-utils",
"watchify": "3.11.0",
"webpack": "4.16.5"
"webpack": "^4.17.1",
"www": "file:packages/www"
},
"dependencies": {
"modular-css-aliases": "file:packages/aliases",
@@ -1,38 +1,38 @@
#!/usr/bin/env node
"use strict";

var fs = require("fs"),
path = require("path"),

mkdirp = require("mkdirp"),
glob = require("modular-css-glob"),
cli = require("meow")(`
Usage
$ modular-css [options] <glob>...
const fs = require("fs");
const path = require("path");

Options
--dir, -d <dir> Directory to search from [process cwd]
--out, -o <file> File to write output CSS to [stdout]
--json, -j <file> File to write output compositions JSON to
--map, -m Include inline source map in output
--rewrite, -r Control rewriting of url() references in CSS
--help Show this help
`, {
alias : {
dir : "d",
json : "j",
map : "m",
out : "o",
rewrite : "r",
},
const mkdirp = require("mkdirp");
const glob = require("modular-css-glob");
const cli = require("meow")(`
Usage
$ modular-css [options] <glob>...
default : {
rewrite : true,
},
Options
--dir, -d <dir> Directory to search from [process cwd]
--out, -o <file> File to write output CSS to [stdout]
--json, -j <file> File to write output compositions JSON to
--map, -m Include inline source map in output
--rewrite, -r Control rewriting of url() references in CSS
--help Show this help
`, {
alias : {
dir : "d",
json : "j",
map : "m",
out : "o",
rewrite : "r",
},

string : [ "dir", "out", "json" ],
boolean : [ "map", "rewrite", "help" ],
});
default : {
rewrite : true,
},

string : [ "dir", "out", "json" ],
boolean : [ "map", "rewrite", "help" ],
});

// It's not immediately obvious, but this ends the program too...
if(!cli.input.length) {
@@ -14,7 +14,7 @@ describe("/cli.js", () => {
cli
);

expect(out.code).toBe(0);
expect(out.code).toBe(2);
expect(out.stdout).toMatchSnapshot();
});

@@ -63,7 +63,7 @@ describe("/cli.js", () => {
it("should support disabling url() rewriting (--no-rewrite)", async () => {
const out = await tester(
cli,
"--rewrite=false",
"--no-rewrite",
"--out=./packages/cli/test/output/no-rewrite.css",
"./packages/cli/test/specimens/no-rewrite.css"
);
@@ -25,7 +25,7 @@
"lodash.mapvalues": "^4.6.0",
"p-each-series": "^1.0.0",
"postcss": "^7.0.0",
"postcss-selector-parser": "^3.0.0",
"postcss-selector-parser": "^4.0.0",
"postcss-url": "^8.0.0",
"postcss-value-parser": "^3.3.0",
"resolve-from": "^4.0.0",
@@ -1,11 +1,11 @@
"use strict";

var processor = require("postcss-selector-parser"),
const processor = require("postcss-selector-parser");

identifiers = require("../lib/identifiers.js"),
const identifiers = require("../lib/identifiers.js");

reuse = "Unable to re-use the same selector for global & local",
plugin = "modular-css-scoping";
const reuse = "Unable to re-use the same selector for global & local";
const plugin = "modular-css-scoping";

// Validate whether a selector should be renamed, returns the key to use
function rename(current, thing) {
@@ -19,13 +19,15 @@ function rename(current, thing) {
}

module.exports = (css, result) => {
var classes = Object.create(null),
keyframes = Object.create(null),
globals = Object.create(null),
parser, current, lookup;
const classes = Object.create(null);
const keyframes = Object.create(null);
const globals = Object.create(null);

parser = processor((selectors) => {
var pseudos = [];
let current;
let lookup;

const parser = processor((selectors) => {
const pseudos = [];

selectors.walkPseudos((node) => {
if(node.value !== ":global") {
@@ -48,7 +50,7 @@ module.exports = (css, result) => {
}));

node.walk((child) => {
var key = rename(current, child);
const key = rename(current, child);

if(!key) {
return;
@@ -70,7 +72,7 @@ module.exports = (css, result) => {
});

selectors.walk((node) => {
var key = rename(current, node);
const key = rename(current, node);

if(!key || node.ignore) {
return;
Oops, something went wrong.

0 comments on commit 14bae1d

Please sign in to comment.
You can’t perform that action at this time.