Skip to content

Commit

Permalink
fix: update stopped working with banner
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laggingreflex committed Nov 29, 2016
1 parent 2450b72 commit 3f70490
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/utilities/validateTargetDirectory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs';
import path from 'path';
import _ from 'lodash';

export default (targetDirectory) => {
let stats;
Expand All @@ -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.');
}

Expand Down

0 comments on commit 3f70490

Please sign in to comment.