Skip to content

Commit 5d80261

Browse files
author
Vincent Maugé
committed
Editor: avoid error when mediadir does not exist
Some apps do not have a media dir under static/apps/<app_name> for example eyeball and hello_coder. When you try to edit the apps with app editor, there is an error display in the consol. The fix checks if the folder exists before reading it.
1 parent 99b70ee commit 5d80261

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

coder-base/apps/editor/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ exports.listMedia = function( appname ) {
335335
var path = process.cwd(); //root application path. different from __dirname
336336
var mediadir = path + "/static/apps/" + appname + "/media/";
337337
var media = {};
338-
var files = fs.readdirSync(mediadir);
338+
var files = fs.existsSync(mediadir) ? fs.readdirSync(mediadir) : {};
339339
for ( var x in files ) {
340340
var filename = files[x];
341341
var info = fs.statSync( mediadir + filename );

0 commit comments

Comments
 (0)