Merge pull request #1552 from ajaxorg/jshint

Jshint update
This commit is contained in:
Lennart Kats 2013-08-12 07:58:32 -07:00
commit 0655f8a809
3 changed files with 2340 additions and 2101 deletions

View file

@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.7 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.1.8+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) { (function (global) {
var req, s, head, baseElement, dataMain, src, var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath, interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.7', version = '2.1.8+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
@ -1609,7 +1609,7 @@ var requirejs, require, define;
//Join the path parts together, then figure out if baseUrl is needed. //Join the path parts together, then figure out if baseUrl is needed.
url = syms.join('/'); url = syms.join('/');
url += (ext || (/\?/.test(url) || skipExt ? '' : '.js')); url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
} }

File diff suppressed because it is too large Load diff

View file

@ -3,18 +3,23 @@ var https = require("https")
, url = require("url") , url = require("url")
, fs = require("fs"); , fs = require("fs");
var Path = require("path");
var spawn = require("child_process").spawn;
var async = require("asyncjs"); var async = require("asyncjs");
var rootDir = __dirname + "/../lib/ace/"; var rootDir = __dirname + "/../lib/ace/";
var deps = [{ var deps = {
csslint: {
path: "mode/css/csslint.js", path: "mode/css/csslint.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js", url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js",
needsFixup: true needsFixup: true
}, { },
requirejs: {
path: "../../demo/kitchen-sink/require.js", path: "../../demo/kitchen-sink/require.js",
url: "https://raw.github.com/jrburke/requirejs/master/require.js", url: "https://raw.github.com/jrburke/requirejs/master/require.js",
needsFixup: false needsFixup: false
}, { },
luaparse: {
path: "mode/lua/luaparse.js", path: "mode/lua/luaparse.js",
url: "https://raw.github.com/oxyc/luaparse/master/luaparse.js", url: "https://raw.github.com/oxyc/luaparse/master/luaparse.js",
needsFixup: true, needsFixup: true,
@ -24,9 +29,29 @@ var deps = [{
"(function (root, name, factory) {\n factory(exports)\n}(this, 'luaparse'," "(function (root, name, factory) {\n factory(exports)\n}(this, 'luaparse',"
) )
} }
}, { },
jshint: {
path: "mode/javascript/jshint.js", path: "mode/javascript/jshint.js",
url: "http://jshint.com/get/jshint-2.1.4.js", url: "http://jshint.com/get/jshint-2.1.9.js",
fetch: function(_, cb) {
//run("npm install jshint@latest", function() {
var base = Path.join(__dirname, "/node_modules/jshint/")
var path = Path.join(base, "/src/stable/jshint")
run('browserify ' + path + ' -i console-browserify -r jshint', function(err, src) {
src = replaceConsoleBrowserify(src);
var version = JSON.parse(fs.readFileSync(base + "package.json")).version
src = [ "// " + version,
"var JSHINT;",
"(function () {",
"require = null;",
src,
"JSHINT = require('jshint').JSHINT;",
"}());"
].join("\n")
cb(err, src);
})
//});
},
needsFixup: true, needsFixup: true,
postProcess: function(src) { postProcess: function(src) {
src = src.replace(/(\],|\{)((?:\d+|"\w+"):\[)/g, "$1\n$2") src = src.replace(/(\],|\{)((?:\d+|"\w+"):\[)/g, "$1\n$2")
@ -50,8 +75,9 @@ var deps = [{
+ 'module.exports = req("jshint");\n'; + 'module.exports = req("jshint");\n';
return src; return src;
} }
}, { },
path: "ext/emmet-core.js", emmet: {
path: "ext/emmet core.js",
url: [ url: [
"https://raw.github.com/sergeche/emmet-sublime/master/emmet/emmet-app.js", "https://raw.github.com/sergeche/emmet-sublime/master/emmet/emmet-app.js",
"https://raw.github.com/sergeche/emmet-sublime/master/emmet/snippets.json" "https://raw.github.com/sergeche/emmet-sublime/master/emmet/snippets.json"
@ -68,49 +94,9 @@ var deps = [{
"});"; "});";
}); });
} }
}]; },
coffee: {
var download = function(href, callback) { fetch: function(){
if (Array.isArray(href))
return async.map(href, download, callback);
var options = url.parse(href);
var protocol = options.protocol === "https:" ? https : http;
console.log("connecting to " + options.host + " " + options.path);
protocol.get(options, function(res) {
var data = "";
res.setEncoding("utf-8");
res.on("data", function(chunk){
data += chunk;
});
res.on("end", function(){
callback(null, data);
});
});
};
var getDep = function(dep) {
download(dep.url, function(err, data) {
if (dep.postProcess)
data = dep.postProcess(data);
if (dep.needsFixup)
data = "define(function(require, exports, module) {\n"
+ data
+ "\n});";
fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){
if (err) throw err;
console.log("File " + dep.path + " saved.");
});
});
};
deps.slice(-1).forEach(getDep);
// coffee-script
void function(){
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/"; var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";
var path = "mode/coffee/"; var path = "mode/coffee/";
@ -173,8 +159,102 @@ void function(){
}); });
}); });
} }
}//(); }
}
};
var download = function(href, callback) {
if (Array.isArray(href))
return async.map(href, download, callback);
var options = url.parse(href);
var protocol = options.protocol === "https:" ? https : http;
console.log("connecting to " + options.host + " " + options.path);
protocol.get(options, function(res) {
var data = "";
res.setEncoding("utf-8");
res.on("data", function(chunk){
data += chunk;
});
res.on("end", function(){
callback(null, data);
});
});
};
var getDep = function(dep) {
if (!dep.fetch)
dep.fetch = download
dep.fetch(dep.url, function(err, data) {
if (dep.postProcess)
data = dep.postProcess(data);
if (dep.needsFixup)
data = "define(function(require, exports, module) {\n"
+ data
+ "\n});";
fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){
if (err) throw err;
console.log("File " + dep.path + " saved.");
});
});
};
function run(cmd, cb) {
var proc = process.platform == "win32"
? spawn("cmd", ["/c", cmd], {cwd: __dirname})
: spawn("bash", ["-c", cmd], {cwd: __dirname});
var result = "", err = "";
proc.stderr.setEncoding("utf8");
proc.stderr.on('data', function (data) {
err += data;
});
proc.stdout.setEncoding("utf8");
proc.stdout.on('data', function (data) {
result += data;
});
proc.on('exit', done);
proc.on('close', done);
function done(code) {
if (code !== 0) {
console.error(cmd + '::: process exited with code :::' + code);
console.error(err)
}
cb(err, result)
}
}
function unquote(str) {
return str.replace(/\\(.)/g, function(x, a) {
return a == "n" ? "\n"
: a == "t" ? "\t"
: a == "r" ? "\r"
: a
});
}
function replaceConsoleBrowserify(str) {
var simpleConsole = function(req,module,exports){
["log", "info", "warn", "error",
"time","timeEnd", "trace", "dir", "assert"
].forEach(function(x) {exports[x] = nop;});
function nop() {}
}
var m = /"console-browserify":(\d+)/.exec(str);
name = m && m[1];
if (name) {
str = str.replace(
"{1:[",
"{" + name + ":[" + simpleConsole + ",{}],\n1:["
)
}
return str;
}
getDep(deps.jshint)