Skip to content

Commit 1f87f9a

Browse files
Beralivgajus
authored andcommitted
feat: cannot use create-index for short folders (#51)
* feat: file cannot be started from _ and be one symbol * test: add children-directories-short-name for readDirectory
1 parent 6aac149 commit 1f87f9a

File tree

6 files changed

+12
-1
lines changed

6 files changed

+12
-1
lines changed

src/utilities/readDirectory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const hasMultipleExtensions = (fileName) => {
1717
};
1818

1919
const isSafeName = (fileName) => {
20-
return /^[a-z][a-z0-9._]+$/i.test(fileName);
20+
return /^[a-z_][a-z0-9._]*$/i.test(fileName);
2121
};
2222

2323
const stripExtension = (fileName) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// @create-index
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// @create-index
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// @create-index
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// @create-index

test/readDirectory.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ describe('readDirectory()', () => {
2121
expect(names).to.deep.equal(['present.js']);
2222
});
2323
});
24+
context('target directory contains child directories (short safe name)', () => {
25+
it('gets names of the children directories', () => {
26+
const names = readDirectory(path.resolve(fixturesPath, 'children-directories-short-name'));
27+
28+
expect(names).to.deep.equal(['F', 'T', '__', 'o']);
29+
});
30+
});
2431
context('target directory contains child directories (unsafe name)', () => {
2532
it('gets names of the children directories', () => {
2633
const names = readDirectory(path.resolve(fixturesPath, 'children-directories-unsafe-name'));

0 commit comments

Comments
 (0)