-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(ref: #22)
- Loading branch information
Showing
11 changed files
with
284 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# rcs.process.pug | ||
|
||
**rcs.process.pug(src[, options][, callback])** | ||
|
||
> **Important!** process.css should run first, otherwise there are no minified selectors | ||
Sync: `process.pugSync` | ||
|
||
Parameters: | ||
- src `<String | Array>` | ||
- options `<Object>` *optional* | ||
- callback `<Function>` *optional* | ||
|
||
Options: | ||
|
||
- *all options of [rcs.process.html](processHtml.md)* | ||
|
||
Example: | ||
|
||
```js | ||
const rcs = require('rename-css-selectors'); | ||
|
||
// callback | ||
rcs.process.pug('**/*.pug', options, (err) => { | ||
if (err) { | ||
return console.error(err); | ||
} | ||
|
||
console.log('Successfully wrote new pug files'); | ||
}); | ||
|
||
// promise | ||
rcs.process.pug('**/*.pug', options) | ||
.then(() => console.log('Successfully wrote new pug files')) | ||
.catch(console.error); | ||
|
||
// async/await | ||
(async () => { | ||
try { | ||
await rcs.process.pug('**/*.pug', options); | ||
|
||
console.log('Successfully wrote new pug files'); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
})(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
doctype html | ||
head | ||
meta(charset='UTF-8') | ||
title Test Document | ||
.jp-block | ||
.jp-block__element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
doctype html | ||
head | ||
meta(charset!='UTF-8') | ||
title Test Document | ||
.a | ||
.b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import test from 'ava'; | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import rcsCore from 'rcs-core'; | ||
|
||
import rcs from '../'; | ||
|
||
const testCwd = 'test/files/testCache'; | ||
const fixturesCwd = 'test/files/fixtures'; | ||
const resultsCwd = 'test/files/results'; | ||
|
||
|
||
test.before(() => { | ||
rcsCore.nameGenerator.setAlphabet('#abcdefghijklmnopqrstuvwxyz'); | ||
rcsCore.nameGenerator.reset(); | ||
rcsCore.selectorLibrary.reset(); | ||
rcsCore.keyframesLibrary.reset(); | ||
|
||
rcsCore.selectorLibrary.fillLibrary(fs.readFileSync(path.join(fixturesCwd, '/css/style.css'), 'utf8')); | ||
}); | ||
|
||
test.afterEach(() => { | ||
fs.removeSync(testCwd); | ||
}); | ||
|
||
test.cb('should process pug files', (t) => { | ||
rcs.process.pug('pug/index.pug', { | ||
newPath: testCwd, | ||
cwd: fixturesCwd, | ||
}, (err) => { | ||
const newFile = fs.readFileSync(path.join(testCwd, '/pug/index.pug'), 'utf8'); | ||
const expectedFile = fs.readFileSync(path.join(resultsCwd, '/pug/index.pug'), 'utf8'); | ||
|
||
t.falsy(err); | ||
t.is(newFile.trim(), expectedFile.trim()); | ||
|
||
t.end(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import test from 'ava'; | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import rcsCore from 'rcs-core'; | ||
|
||
import rcs from '../'; | ||
|
||
const testCwd = 'test/files/testCache'; | ||
const fixturesCwd = 'test/files/fixtures'; | ||
const resultsCwd = 'test/files/results'; | ||
|
||
|
||
test.before(() => { | ||
rcsCore.nameGenerator.setAlphabet('#abcdefghijklmnopqrstuvwxyz'); | ||
rcsCore.nameGenerator.reset(); | ||
rcsCore.selectorLibrary.reset(); | ||
rcsCore.keyframesLibrary.reset(); | ||
|
||
rcsCore.selectorLibrary.fillLibrary(fs.readFileSync(path.join(fixturesCwd, '/css/style.css'), 'utf8')); | ||
}); | ||
|
||
test.afterEach(() => { | ||
fs.removeSync(testCwd); | ||
}); | ||
|
||
test('should process pug files', (t) => { | ||
rcs.process.pugSync('pug/index.pug', { | ||
newPath: testCwd, | ||
cwd: fixturesCwd, | ||
}); | ||
|
||
const newFile = fs.readFileSync(path.join(testCwd, '/pug/index.pug'), 'utf8'); | ||
const expectedFile = fs.readFileSync(path.join(resultsCwd, '/pug/index.pug'), 'utf8'); | ||
|
||
t.is(newFile.trim(), expectedFile.trim()); | ||
}); |
Oops, something went wrong.