[Pkg-javascript-commits] [node-umd] 03/07: Update AMD test and `'use strict'; `

Bastien Roucariès rouca at moszumanska.debian.org
Mon Apr 17 07:38:11 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to annotated tag 2.1.0
in repository node-umd.

commit d196e491b641d477e37f836e10177ee77c82c45b
Author: Forbes Lindesay <forbes.lindesay at red-gate.com>
Date:   Mon Mar 24 12:15:30 2014 +0000

    Update AMD test and `'use strict';`
---
 index.js      | 32 +++++++++++++++++---------------
 test/index.js |  5 ++++-
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/index.js b/index.js
index 5124cdf..e221657 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,10 @@
+'use strict';
+
 var through = require('through');
 var rfile = require('rfile');
-var templateSTR = rfile('./template.js');
 var uglify = require('uglify-js');
+var templateSTR = rfile('./template.js');
+
 function template(moduleName, cjs) {
   var str = uglify.minify(
     templateSTR.replace(/\{\{defineNamespace\}\}/g, compileNamespace(moduleName)),
@@ -25,21 +28,20 @@ exports = module.exports = function (name, cjs, src) {
   }
   if (src) {
     return exports.prelude(name, cjs) + src + exports.postlude(name, cjs);
-  } else {
-    var strm = through(write, end);
-    var first = true;
-    function write(chunk) {
-      if (first) strm.queue(exports.prelude(name, cjs));
-      first = false;
-      strm.queue(chunk);
-    }
-    function end() {
-      if (first) strm.queue(exports.prelude(name, cjs));
-      strm.queue(exports.postlude(name, cjs));
-      strm.queue(null);
-    }
-    return strm;
   }
+  var strm = through(write, end);
+  var first = true;
+  function write(chunk) {
+    if (first) strm.queue(exports.prelude(name, cjs));
+    first = false;
+    strm.queue(chunk);
+  }
+  function end() {
+    if (first) strm.queue(exports.prelude(name, cjs));
+    strm.queue(exports.postlude(name, cjs));
+    strm.queue(null);
+  }
+  return strm;
 };
 
 exports.prelude = function (moduleName, cjs) {
diff --git a/test/index.js b/test/index.js
index af1e505..91ec559 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,3 +1,5 @@
+'use strict';
+
 var assert = require('assert')
 var umd = require('../')
 var src = umd('sentinel-prime', 'return "sentinel"')
@@ -15,7 +17,8 @@ describe('with amd', function () {
   it('uses define', function () {
     var defed
     function define(d, fn) {
-      defed = (typeof d === 'function' ? d: fn)()
+      assert.deepEqual(d, [], 'You must pass an empty array of dependencies to amd to prevent dependency scanning.');
+      defed = fn()
     }
     define.amd = true
     Function('define', src)(define)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-umd.git



More information about the Pkg-javascript-commits mailing list