diff --git a/src/Task.cpp b/src/Task.cpp index 208e09de..d994681b 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -106,6 +106,7 @@ Task::Task() { Task::~Task() { _exportObject.Reset(); _sourceObject.Reset(); + _scriptExports.clear(); { v8::Isolate::Scope isolateScope(_isolate); @@ -286,7 +287,7 @@ bool Task::execute(const char* fileName) { if (position != std::string::npos) { path.resize(position + 1); } else { - path = "."; + path = "./"; } _path.push_back(path); } @@ -721,6 +722,7 @@ std::string Task::resolveRequire(const std::string& require) { if (test.size() && (require.size() < 3 || require.rfind(".js") != require.size() - 3)) { test += ".js"; } + std::cout << "Testing " << test << "\n"; uv_fs_t request; if (uv_fs_access(_loop, &request, test.c_str(), R_OK, 0) == 0) { result = test; diff --git a/tests/11-require b/tests/11-require new file mode 100644 index 00000000..dbeb2dde --- /dev/null +++ b/tests/11-require @@ -0,0 +1,28 @@ +#!/bin/bash + +cat > required.js << EOF +function foo() { + return 12345; +} + +exports.foo = foo; +EOF + +cat > test.js << EOF +if (require("required").foo() != 12345) { + exit(1); +} +var gotError = false; +try { + require("missing"); +} catch (error) { + print("nope"); + gotError = true; +} +if (!gotError) { + exit(2); +} +exit(0); +EOF + +$TILDEFRIENDS test.js diff --git a/tests/12-exit b/tests/12-exit new file mode 100644 index 00000000..7b9fdbb1 --- /dev/null +++ b/tests/12-exit @@ -0,0 +1,10 @@ +#!/bin/bash + +cat > blah.js << EOF +EOF + +cat > test.js << EOF +require("blah"); +EOF + +$TILDEFRIENDS test.js