Skip to content

Commit eccb7f8

Browse files
committed
updated rcs.replace methods to other names
1 parent 62df2e0 commit eccb7f8

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

lib/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ cli.process = (pathString, options, cb) => {
6767
// call in series
6868
// not all selectors are stored, maybe some selectors are duplicated in different files
6969
async.eachSeries(filesArray, (filePath, callback) => {
70-
rcs.replace.replaceCss(path.join(options.cwd, filePath), (err, data) => {
70+
rcs.replace.fileCss(path.join(options.cwd, filePath), (err, data) => {
7171
let joinedPath;
7272

7373
if (err) callback(err);
@@ -92,7 +92,7 @@ cli.process = (pathString, options, cb) => {
9292
// all selectors are collected
9393
// ⚡️ speed it up with async ⚡️
9494
async.each(filesArray, (filePath, callback) => {
95-
rcs.replace.replace(path.join(options.cwd, filePath), (err, data) => {
95+
rcs.replace.file(path.join(options.cwd, filePath), (err, data) => {
9696
let joinedPath;
9797

9898
if (err) callback(err);

lib/utils/options/replace.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const replace = module.exports = {};
2424
*
2525
* @return {Object}
2626
*/
27-
replace.replace = (filepath, options, cb) => {
27+
replace.file = (filepath, options, cb) => {
2828
let result;
2929
let regex;
3030
const optionsDefault = {
@@ -76,7 +76,7 @@ replace.string = (string, regex) => {
7676
* @param {[type]} options [description]
7777
* @return {[type]} [description]
7878
*/
79-
replace.replaceCss = (filepath, options, cb) => {
79+
replace.fileCss = (filepath, options, cb) => {
8080
let result;
8181
// matches from . or # every character until : or . or ) (for pseudo elements or dots or even in :not(.class))
8282
// todo update regex

test/cli.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('cli.js', () => {
8888
});
8989

9090
it('should process js files', done => {
91-
rcs.replace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
91+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
9292
cli.process('**/*.txt', {
9393
newPath: testCwd,
9494
cwd: fixturesCwd
@@ -105,7 +105,7 @@ describe('cli.js', () => {
105105
});
106106

107107
it('should process html files', done => {
108-
rcs.replace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
108+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
109109
cli.process('**/*.html', {
110110
newPath: testCwd,
111111
cwd: fixturesCwd

test/rcs/fileReplace.spec.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ describe('rcs file replace', () => {
1616

1717
describe('replaceCss', () => {
1818
it('should return the modified css file', done => {
19-
rcs.fileReplace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
19+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
2020
expect(data.data).to.equal(fs.readFileSync(resultsCwd + '/style.css', 'utf8'));
2121

2222
done();
2323
});
2424
});
2525

2626
it('should modify the second one with the values from the first', done => {
27-
rcs.fileReplace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
28-
rcs.fileReplace.replaceCss(fixturesCwd + '/style2.css', (err, data) => {
27+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
28+
rcs.replace.fileCss(fixturesCwd + '/style2.css', (err, data) => {
2929
expect(data.data).to.equal(fs.readFileSync(resultsCwd + '/style2.css', 'utf8'));
3030

3131
done();
@@ -34,7 +34,7 @@ describe('rcs file replace', () => {
3434
});
3535

3636
it('should fail', done => {
37-
rcs.fileReplace.replaceCss('non/exisiting/path.css', (err, data) => {
37+
rcs.replace.fileCss('non/exisiting/path.css', (err, data) => {
3838
expect(err).to.be.an('object');
3939
expect(err.error).to.equal('ENOENT');
4040

@@ -45,7 +45,7 @@ describe('rcs file replace', () => {
4545

4646
describe('replace any file', () => {
4747
it('should fail', done => {
48-
rcs.fileReplace.replace('non/exisiting/path.css', (err, data) => {
48+
rcs.replace.file('non/exisiting/path.css', (err, data) => {
4949
expect(err).to.be.an('object');
5050
expect(err.error).to.equal('ENOENT');
5151

@@ -54,8 +54,8 @@ describe('rcs file replace', () => {
5454
});
5555

5656
it('should return the modified html file', done => {
57-
rcs.fileReplace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
58-
rcs.fileReplace.replace(fixturesCwd + '/index.html', (err, data) => {
57+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
58+
rcs.replace.file(fixturesCwd + '/index.html', (err, data) => {
5959
expect(data.data).to.equal(fs.readFileSync(resultsCwd + '/index.html', 'utf8'));
6060

6161
done();
@@ -65,8 +65,8 @@ describe('rcs file replace', () => {
6565

6666
it('should return the modified js file', done => {
6767
// `js` file imported as `txt` to avoid having mocha-phantomjs
68-
rcs.fileReplace.replaceCss(fixturesCwd + '/style.css', (err, data) => {
69-
rcs.fileReplace.replace(fixturesCwd + '/main.txt', (err, data) => {
68+
rcs.replace.fileCss(fixturesCwd + '/style.css', (err, data) => {
69+
rcs.replace.file(fixturesCwd + '/main.txt', (err, data) => {
7070
expect(data.data).to.equal(fs.readFileSync(resultsCwd + '/main.txt', 'utf8'));
7171

7272
done();

0 commit comments

Comments
 (0)