From 2ebf57e3d16c72523f2f06aebeb12c071e633626 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 5 Aug 2012 12:06:14 +0400 Subject: [PATCH 1/3] add ability to run makefile.dryice.js from another directory --- Makefile.dryice.js | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 3b53a2db..80c5ac34 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -43,7 +43,7 @@ if (!fs.existsSync) var copy = require('dryice').copy; var ACE_HOME = __dirname; -var BUILD_DIR = "build"; +var BUILD_DIR = ACE_HOME + "/build"; function main(args) { var type = "minimal"; @@ -146,20 +146,20 @@ function ace() { console.log('# ace License | Readme | Changelog ---------'); copy({ - source: "build_support/editor.html", - dest: "build/editor.html" + source: ACE_HOME + "/build_support/editor.html", + dest: BUILD_DIR + "/editor.html" }); copy({ source: ACE_HOME + "/LICENSE", - dest: "build/LICENSE" + dest: BUILD_DIR + "/LICENSE" }); copy({ source: ACE_HOME + "/Readme.md", - dest: "build/Readme.md" + dest: BUILD_DIR + "/Readme.md" }); copy({ source: ACE_HOME + "/ChangeLog.txt", - dest: "build/ChangeLog.txt" + dest: BUILD_DIR + "/ChangeLog.txt" }); } @@ -168,8 +168,8 @@ function demo() { var version, ref; try { - version = JSON.parse(fs.readFileSync(__dirname + "/package.json")).version; - ref = fs.readFileSync(__dirname + "/.git-ref").toString(); + version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; + ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); } catch(e) { ref = ""; version = ""; @@ -186,7 +186,7 @@ function demo() { } copy({ - source: "kitchen-sink.html", + source: ACE_HOME + "/kitchen-sink.html", dest: BUILD_DIR + "/kitchen-sink.html", filter: [changeComments, function(data) { return data.replace(/"(demo|build)\//g, "\""); @@ -194,21 +194,21 @@ function demo() { }); copy({ - source: "demo/kitchen-sink/styles.css", + source: ACE_HOME + "/demo/kitchen-sink/styles.css", dest: BUILD_DIR + "/kitchen-sink/styles.css", filter: [ changeComments ] }); - fs.readdirSync("demo/kitchen-sink/docs/").forEach(function(x) { + fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) { copy({ - source: "demo/kitchen-sink/docs/" + x, + source: ACE_HOME +"/demo/kitchen-sink/docs/" + x, dest: BUILD_DIR + "/kitchen-sink/docs/" + x }); }); var demo = copy.createDataObject(); copy({ - source: "demo/kitchen-sink/demo.js", + source: ACE_HOME + "/demo/kitchen-sink/demo.js", dest: demo, filter: [changeComments, function(data) { return data.replace(/"(demo|build)\//g, "\""); @@ -217,7 +217,7 @@ function demo() { }] }); copy({ - source: "lib/ace/split.js", + source: ACE_HOME + "/lib/ace/split.js", dest: demo, filter: [changeComments, function(data) { return data.replace("define(", "define('ace/split',"); @@ -228,7 +228,7 @@ function demo() { dest: BUILD_DIR + "/kitchen-sink/demo.js", }); - copyFileSync("demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png"); + copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png"); } function buildAce(options) { @@ -246,13 +246,13 @@ function buildAce(options) { noconflict: false, suffix: null, name: "ace", - modes: fs.readdirSync("lib/ace/mode").map(function(x) { + modes: fs.readdirSync(ACE_HOME + "/lib/ace/mode").map(function(x) { if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x)) return x.slice(0, -3); - }).filter(function(x){return !!x}), - themes: fs.readdirSync("lib/ace/theme").map(function(x){ - return x.slice(-3) == ".js" && x.slice(0, -3) - }).filter(function(x){return !!x}), + }).filter(function(x) { return !!x; }), + themes: fs.readdirSync(ACE_HOME + "/lib/ace/theme").map(function(x){ + return x.slice(-3) == ".js" && x.slice(0, -3); + }).filter(function(x){ return !!x; }), workers: ["javascript", "coffee", "css", "json", "xquery"], keybindings: ["vim", "emacs"] }; @@ -297,7 +297,7 @@ function buildAce(options) { var project = copy.createCommonJsProject(aceProject); var ace = copy.createDataObject(); copy({ - source: ["build_support/mini_require.js"], + source: [ACE_HOME + "/build_support/mini_require.js"], dest: ace }); copy({ @@ -344,7 +344,7 @@ function buildAce(options) { dest: targetDir + "/theme-" + theme + ".js" });*/ // use this instead, to not create separate modules for js and css - var themePath = "lib/ace/theme/" + theme + var themePath = ACE_HOME + "/lib/ace/theme/" + theme var js = fs.readFileSync(themePath + ".js", "utf8"); js = js.replace("define(", "define('ace/theme/" + theme + "', ['require', 'exports', 'module', 'ace/lib/dom'], "); @@ -364,8 +364,8 @@ function buildAce(options) { options.keybindings.forEach(function(keybinding) { copy({ source: [{ - project: cloneProject(project), - require: [ 'ace/keyboard/' + keybinding ] + project: cloneProject(project), + require: [ 'ace/keyboard/' + keybinding ] }], filter: filters, dest: targetDir + "/keybinding-" + keybinding + ".js" From 42219c2379081141c5d9bb49ef70033cd32e53f3 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 5 Aug 2012 14:59:27 +0400 Subject: [PATCH 2/3] include ace/requirejs/text in build to not depend on require text plugin fixes issue #708 --- Makefile.dryice.js | 72 +++++++++++++++++++++-------------- build_support/mini_require.js | 9 ++++- install.js | 13 +------ 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 80c5ac34..a5e65d21 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -34,7 +34,7 @@ * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. - * + * * ***** END LICENSE BLOCK ***** */ var fs = require("fs"); @@ -174,16 +174,21 @@ function demo() { ref = ""; version = ""; } - var changeComments = function(data) { - return (data - .replace(//g, "") - .replace(/PACKAGE\-\->|/g, "") + .replace(/PACKAGE\-\->| Date: Thu, 9 Aug 2012 17:55:40 +0400 Subject: [PATCH 3/3] fix mini_require.js do not patch global require namespace if is used do not patch require if it is already patched --- build_support/mini_require.js | 58 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/build_support/mini_require.js b/build_support/mini_require.js index 5067028e..cc794fb6 100644 --- a/build_support/mini_require.js +++ b/build_support/mini_require.js @@ -49,6 +49,26 @@ var global = (function() { return this; })(); +// take care of the case when requirejs is used and we just need to patch it a little bit +if (!ACE_NAMESPACE && typeof requirejs !== "undefined") { + + var define = global.define; + global.define = function(id, deps, callback) { + if (typeof callback !== "function") + return define.apply(this, arguments); + + return define(id, deps, function(require, exports, module) { + if (deps[2] == "module") + module.packaged = true; + return callback.apply(this, arguments); + }); + }; + global.define.packaged = true; + + return; +} + + var _define = function(module, deps, payload) { if (typeof module !== 'string') { if (_define.original) @@ -160,29 +180,9 @@ var lookup = function(parentId, moduleName) { }; function exportAce(ns) { - - if (typeof requirejs !== "undefined") { - - var define = global.define; - global.define = function(id, deps, callback) { - if (typeof callback !== "function") - return define.apply(this, arguments); - - return define(id, deps, function(require, exports, module) { - if (deps[2] == "module") - module.packaged = true; - return callback.apply(this, arguments); - }); - }; - global.define.packaged = true; - - return; - } - var require = function(module, callback) { return _require("", module, callback); - }; - require.packaged = true; + }; var root = global; if (ns) { @@ -191,15 +191,17 @@ function exportAce(ns) { root = global[ns]; } - if (root.define) + if (!root.define || !root.define.packaged) { _define.original = root.define; + root.define = _define; + root.define.packaged = true; + } - root.define = _define; - - if (root.require) + if (!root.require || !root.require.packaged) { _require.original = root.require; - - root.require = require; + root.require = require; + root.require.packaged = true; + } } exportAce(ACE_NAMESPACE); @@ -211,4 +213,4 @@ define('ace/requirejs/text', ['require', 'exports', 'module'], function(require, exports.load = function (name, req, onLoad, config) { require("ace/lib/net").get(req.toUrl(name), onLoad); }; -}); \ No newline at end of file +});