Skip to content
Browse files

curl now fails if dev supplies a .js extension for a module

  • Loading branch information...
1 parent 1e1115b commit d0deb7c1e81f8a180bd729c104582f6f1b3f7455 @unscriptable unscriptable committed Feb 3, 2013
Showing with 13 additions and 2 deletions.
  1. +10 −2 src/curl.js
  2. +3 −0 test/auto-define.html
View
12 src/curl.js
@@ -938,12 +938,20 @@
args = argsNet;
argsNet = undef; // reset it before we get deps
+ // if the resource is a plain js file, auto-define it here
+ if (/\.js$/.test(def.id)) {
+ if (def.useNet == false || args) {
+ def.reject(new Error('define() found in plain js file.'));
+ }
+ else {
+ define(def.id, undef);
+ }
+ }
+
// if our resource was not explicitly defined with an id (anonymous)
// Note: if it did have an id, it will be resolved in the define()
if (def.useNet !== false) {
- // if the resource is a plain js file, auto-define it here
- if (/\.js$/.test(def.id)) define(def.id, undef);
// if !args, nothing was added to the argsNet
if (!args || args.ex) {
View
3 test/auto-define.html
@@ -29,6 +29,9 @@
curl(['pkg/plain_old.js'])
.then(check, cb.failure)
.then(done, done);
+ },
+ 'curl should error when a module has a .js extension': function (cb, assert, require, done) {
+ curl(['pkg/one.js']).then(cb.failure, cb.success).then(done, done);
}
};

0 comments on commit d0deb7c

Please sign in to comment.
Something went wrong with that request. Please try again.