Skip to content

Fix: forgot to pass ignoreCssVariables options (closes #39) #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/process/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const rcsProcess = (pathString, opts, cb) => {
replaceKeyframes: options.replaceKeyframes,
preventRandomName: options.preventRandomName,
ignoreAttributeSelectors: options.ignoreAttributeSelectors,
ignoreCssVariables: options.ignoreCssVariables,
};

rcs.fillLibraries(bufferData.toString(), availableOptions);
Expand Down
1 change: 1 addition & 0 deletions lib/process/processSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const processSync = (pathString, opts) => {
replaceKeyframes: options.replaceKeyframes,
preventRandomName: options.preventRandomName,
ignoreAttributeSelectors: options.ignoreAttributeSelectors,
ignoreCssVariables: options.ignoreCssVariables,
};

rcs.fillLibraries(fileData.toString(), availableOptions);
Expand Down
98 changes: 98 additions & 0 deletions test/files/results/css/css-variables-ignore.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.a {
--theme-primary: #111;
--theme-secondary: #f0f0f0;
--theme-tertiary: #999;
}

.b {
--theme-primary: red;
--theme-secondary: white;
--theme-tertiary: black;
}

.c {
color: var(--theme-primary);
background-color: var(--theme-secondary);
font-size: 1.2em;
line-height: 1.4;
width: 100%;
max-width: 400px;
padding: 5px;
border: 1px solid var(--theme-tertiary);
margin: 0 0 20px;
}

.d {
content: 'block';
}

.e {
content: 'block__element';
}

.f {
content: 'block__element--modifier';
}

.g{
content: 'block--modifier';
}

.h:before {
content: 'before';
}

.f {
content: 'block__element--modifier';
}

#i {
content: 'id';
}

.j[src] {
content: 'attribute';
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}

@media screen and (min-width: .40em) {
#i {
height: .20px;
width: .20em;
}
}

/**
* a description
*/
@media screen and (min-width: 40em)

{
#i
{
height: .20px;
width: .20em;
}
}

h1 {
color: red;
}

.k {
content: 'reveal';
color: #eee;
font-size: .5rem;
}

.l.k {
content: 'js reveal';
}

.m.k {
content: 'js reveal';
}

.n {
content: 'js-reveal';
}
32 changes: 32 additions & 0 deletions test/processAuto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test.beforeEach(() => {
rcsCore.nameGenerator.reset();
rcsCore.selectorLibrary.reset();
rcsCore.keyframesLibrary.reset();
rcsCore.cssVariablesLibrary.reset();
});

test.afterEach(() => {
Expand Down Expand Up @@ -109,3 +110,34 @@ test.cb('should fail', (t) => {
t.end();
});
});

test.cb('should process auto file with css variables', (t) => {
rcs.process.auto('css/css-variables.css', {
newPath: testCwd,
cwd: fixturesCwd,
}, (err) => {
const newFile = fs.readFileSync(path.join(testCwd, '/css/css-variables.css'), 'utf8');
const expectedFile = fs.readFileSync(path.join(resultsCwd, '/css/css-variables.css'), 'utf8');

t.falsy(err);
t.is(newFile, expectedFile);

t.end();
});
});

test.cb('should not process auto file with css variables', (t) => {
rcs.process.auto('css/css-variables.css', {
newPath: testCwd,
cwd: fixturesCwd,
ignoreCssVariables: true,
}, (err) => {
const newFile = fs.readFileSync(path.join(testCwd, '/css/css-variables.css'), 'utf8');
const expectedFile = fs.readFileSync(path.join(resultsCwd, '/css/css-variables-ignore.css'), 'utf8');

t.falsy(err);
t.is(newFile, expectedFile);

t.end();
});
});