From 5839536cf08dcbae09d7e619f7ee03c712fec27c Mon Sep 17 00:00:00 2001 From: laggingreflex Date: Wed, 30 Nov 2016 18:50:50 +0530 Subject: [PATCH] fix: update stopped working with banner (#22) With the addition of `--banner` option index files no longer start with '// @create-index' This new regex looks for '// @create-index' that are either at the beginning of the file (old behavior) or if it is followed by a newline. Basically it just checks whether it exists in a file or not. Added a test for it now. # Conflicts: # src/utilities/validateTargetDirectory.js --- .../safe-index-with-banner/index.js | 3 +++ test/validateTargetDirectory.js | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 test/fixtures/validate-target-directory/safe-index-with-banner/index.js diff --git a/test/fixtures/validate-target-directory/safe-index-with-banner/index.js b/test/fixtures/validate-target-directory/safe-index-with-banner/index.js new file mode 100644 index 0000000..69a1f5b --- /dev/null +++ b/test/fixtures/validate-target-directory/safe-index-with-banner/index.js @@ -0,0 +1,3 @@ +/* eslint-disable */ + +// @create-index diff --git a/test/validateTargetDirectory.js b/test/validateTargetDirectory.js index f75f96d..44f7c55 100644 --- a/test/validateTargetDirectory.js +++ b/test/validateTargetDirectory.js @@ -36,6 +36,11 @@ describe('validateTargetDirectory()', () => { expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index'))).to.equal(true); }); }); + context('safe with banner', () => { + it('returns true', () => { + expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index-with-banner'))).to.equal(true); + }); + }); context('unsafe', () => { it('throws an error', () => { expect(() => {