From 3f7049071a835136709445aaff567a8205beb492 Mon Sep 17 00:00:00 2001 From: laggingreflex Date: Wed, 30 Nov 2016 00:13:39 +0530 Subject: [PATCH] fix: update stopped working with banner 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. --- src/utilities/validateTargetDirectory.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utilities/validateTargetDirectory.js b/src/utilities/validateTargetDirectory.js index 4f917fa..48a4c6e 100644 --- a/src/utilities/validateTargetDirectory.js +++ b/src/utilities/validateTargetDirectory.js @@ -1,6 +1,5 @@ import fs from 'fs'; import path from 'path'; -import _ from 'lodash'; export default (targetDirectory) => { let stats; @@ -25,7 +24,7 @@ export default (targetDirectory) => { const indexFile = fs.readFileSync(indexFilePath, 'utf8'); - if (!_.startsWith(indexFile, '// @create-index\n')) { + if (!indexFile.match(/(?:^|[\n\r]+)\/\/ @create-index[\n\r]+/)) { throw new Error('"' + indexFilePath + '" unsafe index.'); }