Browse Source

devkit: release 0.6.0; used in Amber itself

Herbert Vojčík 9 years ago
parent
commit
5b446a58ec
3 changed files with 23 additions and 21 deletions
  1. 4 2
      Gruntfile.js
  2. 17 17
      external/amber-dev/lib/helpers.js
  3. 2 2
      external/amber-dev/package.json

+ 4 - 2
Gruntfile.js

@@ -88,8 +88,9 @@ module.exports = function (grunt) {
                         // none, for repl to have all info
                     },
                     include: ['config-node', 'app'],
+                    insertRequire: ['app'],
                     optimize: "none",
-                    wrap: helpers.nodeWrap('app'),
+                    wrap: helpers.nodeWrapperWithShebang,
                     out: "external/amber-cli/support/amber-cli.js"
                 }
             },
@@ -109,8 +110,9 @@ module.exports = function (grunt) {
                         // none, amber tests test contexts as well as eg. class copying which needs sources
                     },
                     include: ['config-node', 'app'],
+                    insertRequire: ['app'],
                     optimize: "none",
-                    wrap: helpers.nodeWrap('app'),
+                    wrap: helpers.nodeWrapperWithShebang,
                     out: "test_runner.js"
                 }
             }

+ 17 - 17
external/amber-dev/lib/helpers.js

@@ -1,26 +1,26 @@
-exports.libPath = __dirname;
-
-exports.nodeShebang = "#!/usr/bin/env node";
-
-exports.nodeWrap = function (id) {
-    var wrap = exports.nodeWrapWithoutShebang(id);
-    wrap.start = exports.nodeShebang + "\n" + wrap.start;
-    return wrap;
-};
-
-exports.nodeWrapWithoutShebang = function (id) {
-    var wrapSource = JSON.stringify('_wrap_' + id),
-        idSource = JSON.stringify(id);
+function nodeWrapper() {
     return {
         start: "(function(define, require){\n" +
-        "define(" + wrapSource + ", function (requirejs) {\n" +
+        "define('__wrap__', function (requirejs) {\n" +
         "requirejs.resolve = require.resolve;\n" +
         "require = requirejs;\n",
-        end: "require(" + idSource + ");\n" +
-        "});\n" +
-        "define.require(" + wrapSource + ");\n" +
+        end: "});\n" +
+        "define.require('__wrap__');\n" +
         "}((" +
         require("amdefine") +
         "(module)), require));"
     };
+}
+
+var SHEBANG = "#!/usr/bin/env node",
+    WRAPPER = nodeWrapper(),
+    WRAPPER_WITH_SHEBANG = nodeWrapper();
+
+WRAPPER_WITH_SHEBANG.start = SHEBANG + "\n" + WRAPPER_WITH_SHEBANG.start;
+
+module.exports = {
+    libPath: __dirname,
+    nodeShebang: SHEBANG,
+    nodeWrapper: WRAPPER,
+    nodeWrapperWithShebang: WRAPPER_WITH_SHEBANG
 };

+ 2 - 2
external/amber-dev/package.json

@@ -1,6 +1,6 @@
 {
   "name": "amber-dev",
-  "version": "0.5.3",
+  "version": "0.6.0",
   "description": "Development goodies for Amber Smalltalk",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
@@ -16,7 +16,7 @@
   },
   "dependencies": {
     "amd-config-builder": "^0.2.0",
-    "amdefine": ">=0.1.0",
+    "amdefine": ">=0.1.1",
     "es6-promise": "^2.0.0"
   }
 }