Skip to content

Commit

Permalink
Coverage back to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreisnz committed Sep 14, 2017
1 parent 8b45fe7 commit ae5acca
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/helpers/glob-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ const glob = require('glob');
* Async wrapper for glob
*/
module.exports = function globAsync(pattern, ignore, allowEmptyPaths) {

//Ensure array
if (!Array.isArray(ignore)) {
ignore = [ignore];
}

//Return promise
return new Promise((resolve, reject) => {
glob(pattern, {ignore, nodir: true}, (error, files) => {

Expand Down
41 changes: 41 additions & 0 deletions lib/replace-in-file.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,21 @@ describe('Replace in file', () => {
done();
});
});

it('should work without expanding globs if disabled', done => {
replace({
files: ['test1', 'test2'],
from: /re\splace/g,
to: 'b',
disableGlobs: true,
}, () => {
const test1 = fs.readFileSync('test1', 'utf8');
const test2 = fs.readFileSync('test2', 'utf8');
expect(test1).to.equal('a b c');
expect(test2).to.equal('a b c');
done();
});
});
});

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

it('should support an array of ignored files', () => {
replace.sync({
files: 'test*',
ignore: ['test1', 'test3'],
from: /re\splace/g,
to: 'b',
});
const test1 = fs.readFileSync('test1', 'utf8');
const test2 = fs.readFileSync('test2', 'utf8');
expect(test1).to.equal('a re place c');
expect(test2).to.equal('a b c');
});

it('should not fail when the ignore parameter is undefined', () => {
replace.sync({
files: 'test*',
Expand All @@ -726,5 +754,18 @@ describe('Replace in file', () => {
expect(test1).to.equal('a b c');
expect(test2).to.equal('a b c');
});

it('should work without expanding globs if disabled', () => {
replace.sync({
files: ['test1', 'test2'],
from: /re\splace/g,
to: 'b',
disableGlobs: true,
});
const test1 = fs.readFileSync('test1', 'utf8');
const test2 = fs.readFileSync('test2', 'utf8');
expect(test1).to.equal('a b c');
expect(test2).to.equal('a b c');
});
});
});

0 comments on commit ae5acca

Please sign in to comment.