Skip to content

Commit 9dd10b5

Browse files
committed
fixes allNames bug
1 parent a9e9630 commit 9dd10b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/imageFiles.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import path from 'path';
33

44
const DEFAULT_IMAGE_DIR = path.join(__dirname, '..', 'img');
55

6-
export const dirFor = (type, imageDir) => {
6+
export const dirFor = (type, imageDir = DEFAULT_IMAGE_DIR) => {
77
if (type) return path.join(imageDir, type);
88
else return imageDir;
99
};
1010

11-
export const allNames = (type) => {
12-
return fs.readdirSync(dirFor(type)).filter(function(imageFileName) {
11+
export const allNames = (type, imageDir = DEFAULT_IMAGE_DIR) => {
12+
return fs.readdirSync(dirFor(type, imageDir)).filter(function(imageFileName) {
1313
return imageFileName.match(/\.png/);
1414
}).map(function(imageFileName) {
1515
return imageFileName.replace(/\.png/, '');
@@ -19,11 +19,11 @@ export const allNames = (type) => {
1919
export const allPaths = (type, imageDir = DEFAULT_IMAGE_DIR) => {
2020
var dir;
2121
dir = dirFor(type, imageDir);
22-
return allNames(type).map(function(name) {
22+
return allNames(type, imageDir).map(function(name) {
2323
return path.join(dir, name + '.png');
2424
});
2525
};
2626

27-
export const pathFor = (type, fileName) => {
28-
return path.join(dirFor(type), fileName + '.png');
27+
export const pathFor = (type, fileName, imageDir = DEFAULT_IMAGE_DIR) => {
28+
return path.join(dirFor(type, imageDir), fileName + '.png');
2929
};

0 commit comments

Comments
 (0)