forked from cory/tildefriends
Fix a bug that was preventing require('ui') from working, and improve resolveRequire while I'm in there.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3195 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
4b2877dbad
commit
bea0ae23dd
@ -124,7 +124,7 @@ function editPage(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Why do I need .js?
|
// XXX: Why do I need .js?
|
||||||
require("ui.js").fileList({
|
require("ui").fileList({
|
||||||
title: "Live Markdeep Editor",
|
title: "Live Markdeep Editor",
|
||||||
edit: editPage,
|
edit: editPage,
|
||||||
});
|
});
|
13
src/Task.cpp
13
src/Task.cpp
@ -726,15 +726,20 @@ void Task::configureFromStdin() {
|
|||||||
|
|
||||||
std::string Task::resolveRequire(const std::string& require) {
|
std::string Task::resolveRequire(const std::string& require) {
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
for (size_t i = 0; i < _path.size(); ++i) {
|
for (size_t i = 0; i < _path.size(); ++i) {
|
||||||
std::string& path = _path[i];
|
std::string& path = _path[i];
|
||||||
std::cout << "Looking in " << path << " for " << require << "\n";
|
std::cout << "Looking in " << path << " for " << require << "\n";
|
||||||
|
std::string test;
|
||||||
if (require.find("..") == std::string::npos && require.find('/') == std::string::npos) {
|
if (require.find("..") == std::string::npos && require.find('/') == std::string::npos) {
|
||||||
result = path + require;
|
test = path + require;
|
||||||
}
|
}
|
||||||
if (result.size() && require.rfind(".js") != require.size() - 3) {
|
if (test.size() && (require.size() < 3 || require.rfind(".js") != require.size() - 3)) {
|
||||||
result += ".js";
|
test += ".js";
|
||||||
|
}
|
||||||
|
uv_fs_t request;
|
||||||
|
if (uv_fs_access(_loop, &request, test.c_str(), R_OK, 0) == 0) {
|
||||||
|
result = test;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user