simplify config
This commit is contained in:
parent
4abb08fa92
commit
6bb805b40f
5 changed files with 44 additions and 24 deletions
|
|
@ -43,7 +43,7 @@ var copy = require('dryice').copy;
|
|||
var ACE_HOME = __dirname;
|
||||
|
||||
function main(args) {
|
||||
var target;
|
||||
var target = "minimal";
|
||||
if (args.length == 3) {
|
||||
target = args[2];
|
||||
// Check if 'target' contains some allowed value.
|
||||
|
|
@ -52,12 +52,13 @@ function main(args) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
if (target == "help") {
|
||||
console.log("--- Ace Dryice Build Tool ---");
|
||||
console.log("");
|
||||
console.log("Options:");
|
||||
console.log(" minimal Runs minimal build of Ace");
|
||||
console.log(" normal Runs embedded build of Ace");
|
||||
console.log(" demo Runs demo build of Ace");
|
||||
console.log(" demo Runs demo build of Ace");
|
||||
console.log(" bm Runs bookmarklet build of Ace");
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
@ -70,6 +71,15 @@ function main(args) {
|
|||
textPluginPattern: /^ace\/requirejs\/text!/
|
||||
};
|
||||
|
||||
if (target == "minimal") {
|
||||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: "",
|
||||
compat: true,
|
||||
name: "ace"
|
||||
});
|
||||
}
|
||||
if (target == "normal") {
|
||||
ace(aceProject);
|
||||
}
|
||||
|
|
@ -113,14 +123,14 @@ function ace(aceProject) {
|
|||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: "-uncompressed.js",
|
||||
suffix: "-uncompressed",
|
||||
compat: true,
|
||||
name: "ace"
|
||||
});
|
||||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: true,
|
||||
suffix: "-uncompressed-noconflict.js",
|
||||
suffix: "-uncompressed-noconflict",
|
||||
compat: true,
|
||||
name: "ace",
|
||||
workers: []
|
||||
|
|
@ -130,7 +140,7 @@ function ace(aceProject) {
|
|||
buildAce(aceProject, {
|
||||
compress: true,
|
||||
noconflict: false,
|
||||
suffix: ".js",
|
||||
suffix: "",
|
||||
compat: true,
|
||||
name: "ace",
|
||||
workers: []
|
||||
|
|
@ -138,7 +148,7 @@ function ace(aceProject) {
|
|||
buildAce(aceProject, {
|
||||
compress: true,
|
||||
noconflict: true,
|
||||
suffix: "-noconflict.js",
|
||||
suffix: "-noconflict",
|
||||
compat: true,
|
||||
name: "ace",
|
||||
workers: []
|
||||
|
|
@ -199,7 +209,7 @@ function demo(aceProject) {
|
|||
noconflict: false,
|
||||
compat: false,
|
||||
name: "kitchen-sink",
|
||||
suffix: "-uncompressed.js",
|
||||
suffix: "",
|
||||
keybindings: []
|
||||
});
|
||||
}
|
||||
|
|
@ -213,7 +223,7 @@ function buildAce(aceProject, options) {
|
|||
requires: null,
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: ".js",
|
||||
suffix: "",
|
||||
name: "ace",
|
||||
compat: true,
|
||||
modes: [
|
||||
|
|
@ -252,6 +262,15 @@ function buildAce(aceProject, options) {
|
|||
var exportFilter = exportAce(options.ns, options.exportModule);
|
||||
}
|
||||
|
||||
// remove use strict
|
||||
filters.push(function(text) {
|
||||
return text.replace(/['"]use strict['"];/g, "");
|
||||
})
|
||||
// remove redundant comments
|
||||
filters.push(function(text) {
|
||||
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
||||
})
|
||||
|
||||
if (options.compress)
|
||||
filters.push(copy.filter.uglifyjs);
|
||||
|
||||
|
|
@ -279,7 +298,7 @@ function buildAce(aceProject, options) {
|
|||
copy({
|
||||
source: ace,
|
||||
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
||||
dest: targetDir + '/' + name + suffix
|
||||
dest: targetDir + suffix + '/' + name + ".js"
|
||||
});
|
||||
|
||||
if (options.compat) {
|
||||
|
|
@ -292,7 +311,7 @@ function buildAce(aceProject, options) {
|
|||
}
|
||||
],
|
||||
filter: filters,
|
||||
dest: targetDir + "/" + name + "-compat" + suffix
|
||||
dest: targetDir + suffix + "/" + name + "-compat.js"
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +328,7 @@ function buildAce(aceProject, options) {
|
|||
}
|
||||
],
|
||||
filter: filters,
|
||||
dest: targetDir + "/mode-" + mode + suffix
|
||||
dest: targetDir + suffix + "/mode-" + mode + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -324,7 +343,7 @@ function buildAce(aceProject, options) {
|
|||
require: ["ace/theme/" + theme]
|
||||
}],
|
||||
filter: filters,
|
||||
dest: targetDir + "/theme-" + theme + suffix
|
||||
dest: targetDir + suffix + "/theme-" + theme + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -377,7 +396,7 @@ function buildAce(aceProject, options) {
|
|||
}
|
||||
],
|
||||
filter: filters,
|
||||
dest: "build/src/keybinding-" + keybinding + suffix
|
||||
dest: targetDir + suffix + "/keybinding-" + keybinding + ".js"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -423,10 +442,12 @@ function exportAce(ns, module, requireBase) {
|
|||
var template = function() {
|
||||
(function() {
|
||||
REQUIRE_NS.require(["MODULE"], function(a) {
|
||||
a.config.init();
|
||||
if (!window.NS)
|
||||
window.NS = {};
|
||||
for (var key in a) if (a.hasOwnProperty(key))
|
||||
NS[key] = a[key];
|
||||
require("./config").init();
|
||||
});
|
||||
})();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@
|
|||
<!--DEVEL -->
|
||||
|
||||
<!--PACKAGE
|
||||
<script src="demo/kitchen-sink/kitchen-sink-uncompressed.js" data-ace-suffix="-uncompressed.js" data-ace-base="demo/kitchen-sink" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="demo/kitchen-sink/kitchen-sink.js" data-ace-base="demo/kitchen-sink" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require("kitchen-sink/demo");
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ require("./worker/worker_client");
|
|||
require("./keyboard/hash_handler");
|
||||
require("./keyboard/state_handler");
|
||||
require("./placeholder");
|
||||
require("./config").init();
|
||||
|
||||
exports.config = require("./config");
|
||||
/**
|
||||
* Ace.edit(el) -> Editor
|
||||
* - el (String | DOMElement): Either the id of an element, or the element itself
|
||||
|
|
@ -76,6 +75,9 @@ exports.edit = function(el) {
|
|||
el = document.getElementById(el);
|
||||
}
|
||||
|
||||
if (el.env && el.env.editor instanceof Editor)
|
||||
return el.env.editor;
|
||||
|
||||
var doc = new EditSession(Dom.getInnerText(el));
|
||||
doc.setUndoManager(new UndoManager());
|
||||
el.innerHTML = '';
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ exports.init = function() {
|
|||
|
||||
var scriptOptions = {};
|
||||
var scriptUrl = "";
|
||||
var suffix;
|
||||
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
for (var i=0; i<scripts.length; i++) {
|
||||
|
|
@ -98,10 +97,9 @@ exports.init = function() {
|
|||
}
|
||||
}
|
||||
|
||||
var m = src.match(/^(?:(.*\/)ace\.js|(.*\/)ace((-uncompressed)?(-noconflict)?\.js))(?:\?|$)/);
|
||||
var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/);
|
||||
if (m) {
|
||||
scriptUrl = m[1] || m[2];
|
||||
suffix = m[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +108,6 @@ exports.init = function() {
|
|||
scriptOptions.packaged = true;
|
||||
}
|
||||
|
||||
scriptOptions.suffix = scriptOptions.suffix || suffix;
|
||||
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
|
||||
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
|
||||
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@ var EditSession = function(text, mode) {
|
|||
return callback();
|
||||
|
||||
var base = mode.split("/").pop();
|
||||
var filename = config.get("modePath") + "/mode-" + base + config.get("suffix");
|
||||
var filename = config.get("modePath") + "/mode-" + base + ".js";
|
||||
net.loadScript(filename, callback);
|
||||
}
|
||||
};
|
||||
|
|
@ -820,8 +820,8 @@ var EditSession = function(text, mode) {
|
|||
} else {
|
||||
this.bgTokenizer.setTokenizer(tokenizer);
|
||||
}
|
||||
this.bgTokenizer.setDocument(this.getDocument());
|
||||
|
||||
this.bgTokenizer.setDocument(this.getDocument());
|
||||
|
||||
this.tokenRe = this.$mode.tokenRe;
|
||||
this.nonTokenRe = this.$mode.nonTokenRe;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue