Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Warn when level does not exists or does not contain .bem subdirectory #445

Merged
merged 1 commit into from
Sep 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ var PATH = require('./path'),
return bemUtil.requireWrapper(require)(path, true);
},

checkedLevels = {},

checkLevel = function(path) {
if (checkedLevels[path]) {
return;
}
checkedLevels[path] = true;
if (!bemUtil.isDirectory(path)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что, если уровень — симлинка?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statSync ходит по линкам.

LOGGER.fwarn('Level at %s is not a directory', path);
return;
}
if (!bemUtil.isDirectory(PATH.join(path, '.bem'))) {
LOGGER.fwarn('Level at %s does not contain .bem subdirectory', path);
}
},

levelCache = {},
useCache = false,
exceptLevels = [],
Expand All @@ -40,6 +56,8 @@ exports.createLevel = function(level, opts) {

opts = opts || {};

checkLevel(level);

if (!opts.noCache && levelCache[path]) return levelCache[path];
level = new (getLevelClass(PATH.resolve(path, '.bem', 'level.js'), true))(level, opts);
levelCache[path] = level;
Expand Down