Skip to content

Commit ae5acca

Browse files
committed
Coverage back to 100%
1 parent 8b45fe7 commit ae5acca

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

lib/helpers/glob-async.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ const glob = require('glob');
99
* Async wrapper for glob
1010
*/
1111
module.exports = function globAsync(pattern, ignore, allowEmptyPaths) {
12-
13-
//Ensure array
14-
if (!Array.isArray(ignore)) {
15-
ignore = [ignore];
16-
}
17-
18-
//Return promise
1912
return new Promise((resolve, reject) => {
2013
glob(pattern, {ignore, nodir: true}, (error, files) => {
2114

lib/replace-in-file.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,21 @@ describe('Replace in file', () => {
504504
done();
505505
});
506506
});
507+
508+
it('should work without expanding globs if disabled', done => {
509+
replace({
510+
files: ['test1', 'test2'],
511+
from: /re\splace/g,
512+
to: 'b',
513+
disableGlobs: true,
514+
}, () => {
515+
const test1 = fs.readFileSync('test1', 'utf8');
516+
const test2 = fs.readFileSync('test2', 'utf8');
517+
expect(test1).to.equal('a b c');
518+
expect(test2).to.equal('a b c');
519+
done();
520+
});
521+
});
507522
});
508523

509524
/**
@@ -714,6 +729,19 @@ describe('Replace in file', () => {
714729
expect(test2).to.equal('a b c');
715730
});
716731

732+
it('should support an array of ignored files', () => {
733+
replace.sync({
734+
files: 'test*',
735+
ignore: ['test1', 'test3'],
736+
from: /re\splace/g,
737+
to: 'b',
738+
});
739+
const test1 = fs.readFileSync('test1', 'utf8');
740+
const test2 = fs.readFileSync('test2', 'utf8');
741+
expect(test1).to.equal('a re place c');
742+
expect(test2).to.equal('a b c');
743+
});
744+
717745
it('should not fail when the ignore parameter is undefined', () => {
718746
replace.sync({
719747
files: 'test*',
@@ -726,5 +754,18 @@ describe('Replace in file', () => {
726754
expect(test1).to.equal('a b c');
727755
expect(test2).to.equal('a b c');
728756
});
757+
758+
it('should work without expanding globs if disabled', () => {
759+
replace.sync({
760+
files: ['test1', 'test2'],
761+
from: /re\splace/g,
762+
to: 'b',
763+
disableGlobs: true,
764+
});
765+
const test1 = fs.readFileSync('test1', 'utf8');
766+
const test2 = fs.readFileSync('test2', 'utf8');
767+
expect(test1).to.equal('a b c');
768+
expect(test2).to.equal('a b c');
769+
});
729770
});
730771
});

0 commit comments

Comments
 (0)