add id to all modes

This commit is contained in:
nightwing 2013-12-05 23:38:45 +04:00
commit a0ab8baa56
99 changed files with 121 additions and 5 deletions

View file

@ -41,6 +41,9 @@ var ACE_HOME = __dirname;
var BUILD_DIR = ACE_HOME + "/build";
function main(args) {
if (args.indexOf("updateModes") !== -1) {
return updateModes();
}
var type = "minimal";
args = args.map(function(x) {
if (x[0] == "-" && x[1] != "-")
@ -258,10 +261,13 @@ function jsFileList(path, filter) {
}
function workers(path) {
return jsFileList(path).map(function(x) {
if (x.slice(-7) == "_worker")
return x.slice(0, -7);
}).filter(function(x) { return !!x; });
return jsFileList(path).map(function(x) {
if (x.slice(-7) == "_worker")
return x.slice(0, -7);
}).filter(function(x) { return !!x; });
}
function modeList() {
return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/)
}
function addSuffix(options) {
@ -317,7 +323,7 @@ var buildAce = function(options) {
noconflict: false,
suffix: null,
name: "ace",
modes: jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/),
modes: modeList(),
themes: jsFileList("lib/ace/theme"),
extensions: jsFileList("lib/ace/ext"),
workers: workers("lib/ace/mode"),
@ -657,6 +663,18 @@ function exportAce(ns, module, requireBase) {
};
}
function updateModes() {
modeList().forEach(function(m) {
var filepath = __dirname + "/lib/ace/mode/" + m + ".js"
var source = fs.readFileSync(filepath, "utf8");
if (!/this.\$id\s*=\s*"/.test(source))
source = source.replace(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2');
source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"');
fs.writeFileSync(filepath, source, "utf8")
})
}
if (!module.parent)
main(process.argv);
else