<commit_before>/*
 *  Modular - JavaScript AMD Framework
 *  Copyright (c) 2012 http://ovms.co. All Rights Reserved.
 *
 *  ====
 *
 *  This file is part of Modular.
 *
 *  Modular is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Modular is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Modular.  If not, see <http://www.gnu.org/licenses/>.
 */

/*global define, require */

(function () {
    "use strict";

    function each(obj, callback) {
        var key,
            length;

        if (!obj) {
            return;
        }

        if (obj.hasOwnProperty("length")) {
            for (key = 0, length = obj.length; key < length; key += 1) { // Keep JSLint happy with "+= 1"
                if (callback.call(obj[key], obj[key], key) === false) {
                    break;
                }
            }
        } else {
            for (key in obj) {
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        }
    }

    // For Closure compiler name-munging while keeping JSLint happy
    function lookup(obj, name) {
        return obj[name];
    }

    var global = new [Function][0]("return this;")(), // Keep JSLint happy
        defaults = {
            "baseUrl": "",
            "paths": {},
            "pathFilter": function (path) {
                return path;
            },
            "versions": {},
            "versionFilter": function (stack, path, version) {
                var val = stack[0];

                if (path === "jquery" && version) {
                    val = null;

                    each(stack, function () {
                        if (lookup(this(), "jquery") === version) {
                            val = this;

                            return false;
                        }
                    });
                }

                return {
                    val: val
                };
            },
            "fetch": function (config, path, ready) {},
            "anonymous": function (args) {}
        },
        pendings = {},
        modules = {},
        empty = {};

    function extend(target) {
        each([].slice.call(arguments, 1), function () {
            each(this, function (val, key) {
                target[key] = val;
            });
        });

        return target;
    }

    function getType(obj) {
        return {}.toString.call(obj).match(/\[object ([\s\S]*)\]/)[1];
    }

    function isString(str) {
        return typeof str === "string" || getType(str) === "String";
    }

    function isPlainObject(obj) {
        return getType(obj) === "Object";
    }

    function isArray(str) {
        return getType(str) === "Array";
    }

    function isFunction(str) {
        return getType(str) === "Function";
    }

    function getBasePath(path) {
        path = path.replace(/[^\/]+$/, "");

        if (path.charAt(path.length - 1) !== "/") {
            path += "/";
        }

        return path;
    }

    function implicitExtension(path) {
        if (path.substr(path.length - 3) !== ".js") {
            path += ".js";
        }

        return path;
    }

    function makePath(basePath, currentPath, path, config) {
        var previousPath = "",
            components = lookup(config, "pathFilter")(path).split("/");

        each(lookup(config, "paths"), function (to, from) {
            if (components[0] === from) {
                components[0] = to;
            }
        });

        path = components.join("/");

        path = getBasePath(/^\.\.?\//.test(path) ? currentPath : basePath) + path;

        path = path.replace(/\/\.\//g, "/"); // Resolve same-directory symbols

        // Resolve parent-directory symbols
        while (previousPath !== path) {
            previousPath = path;
            path = path.replace(/[^\/]*\/\.\.\//, "");
        }

        return implicitExtension(path);
    }

    function parse(arg1, arg2, arg3, arg4) {
        var config,
            path,
            dependencies,
            closure;

        if (isPlainObject(arg1)) {
            config = arg1;
        } else if (isString(arg1)) {
            path = arg1;
        } else if (isArray(arg1)) {
            dependencies = arg1;
        } else if (isFunction(arg1)) {
            closure = arg1;
        }

        if (isString(arg2)) {
            path = arg2;
        } else if (isArray(arg2)) {
            dependencies = arg2;
        } else if (isFunction(arg2)) {
            closure = arg2;
        }

        if (isArray(arg3)) {
            dependencies = arg3;
        } else if (isFunction(arg3)) {
            closure = arg3;
        }

        if (isFunction(arg4)) {
            closure = arg4;
        }

        if (config && !path && !dependencies && !closure) {
            closure = config;
            config = null;
        }

        return {
            config: config || {},
            path: path || null,
            dependencies: dependencies || [],
            closure: closure || function () {}
        };
    }

    function getModule(path, config) {
        var result = null;

        if (!modules.hasOwnProperty(path)) {
            return null;
        }

        return lookup(config, "versionFilter")(modules[path], path, lookup(config, "versions")[path]);
    }

    function addModule(path, val) {
        if (!modules[path]) {
            modules[path] = [];
        }

        modules[path].push(val);
    }

    function depend(path, fetch, recheck) {
        if (!pendings[path]) {
            pendings[path] = [];

            fetch(path);
        }

        if (recheck) {
            pendings[path].push(recheck);
        }
    }

    function ready(config, path, dependencies, closure, options) {
        var fetched = false;

        function processDependents(moduleValue) {
            var callbacks;

            // Caching may be explicitly disabled, eg. for scoped requires (which would otherwise
            //  overwrite their container module)
            if (options.cache !== false) {
                addModule(path, moduleValue);

                if (pendings[path]) {
                    callbacks = pendings[path];

                    delete pendings[path];

                    each(callbacks, function (dependencyLoaded) {
                        dependencyLoaded();
                    });
                }
            }
        }

        function checkDependencies() {
            var allResolved = true,
                moduleValue = null,
                args = [];

            each(dependencies, function (dependencyPath) {
                var fullPath = makePath(lookup(config, "baseUrl"), path, dependencyPath, config),
                    result;

                // Scoped require support
                if (dependencyPath === "require") {
                    args.push(function (arg1, arg2, arg3, arg4) {
                        var args = parse(arg1, arg2, arg3, arg4);

                        ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure, {
                            cache: false
                        });
                    });
                // Exports support
                } else if (dependencyPath === "exports") {
                    moduleValue = {};
                    args.push(moduleValue);
                } else {
                    result = getModule(dependencyPath, config) || getModule(fullPath, config);

                    if (result) {
                        args.push(result.val);
                    } else {
                        if (!fetched) {
                            depend(fullPath, function (path) {
                                lookup(config, "fetch")(config, path, ready);
                            }, checkDependencies);
                        }

                        allResolved = false;
                    }
                }
            });

            fetched = true;

            if (allResolved) {
                moduleValue = (isFunction(closure) ? closure.apply(global, args) : closure) || moduleValue;

                processDependents(moduleValue);
            }
        }

        options = options || {};

        checkDependencies();
    }

    function require(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4);

        ready(extend({}, defaults, args.config), args.path || lookup(args.config, "baseUrl"), args.dependencies, args.closure);
    }

    function define(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4),
            config = extend({}, defaults, args.config);

        if (args.path) {
            ready(config, args.path, args.dependencies, args.closure);
        } else {
            lookup(config, "anonymous")(args);
        }
    }

    extend(require, {
        "config": function (config) {
            extend(defaults, config);
        },
        "onError": function (msg) {
            throw new Error(msg);
        }
    });

    extend(define, {
        // Publish support for the AMD pattern
        "amd": {
            "jQuery": true
        }
    });

    // Exports
    extend(global, {
        "require": require,
        "requirejs": require,
        "define": define
    });

    // Browser environment support
    if (global.document) {
        (function (document) {
            var scripts = document.getElementsByTagName("script"),
                head = scripts[0].parentNode,
                on = head.addEventListener ? function (node, type, callback) {
                    node.addEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.attachEvent("on" + type, callback);
                },
                off = head.removeEventListener ? function (node, type, callback) {
                    node.removeEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.detachEvent("on" + type, callback);
                },
                useOnLoad = head.addEventListener && (!head.attachEvent || global.opera),
                useDOMContentLoaded = {}.hasOwnProperty.call(global, "DOMContentLoaded"),
                jQuery = lookup(global, "jQuery"),
                anonymouses = [];

            extend(defaults, {
                "baseUrl": global.location.pathname,
                // Overridable - called when a module needs to be loaded
                "fetch": function (config, path, ready) {
                    var script = document.createElement("script");

                    on(script, useOnLoad ? "load" : "readystatechange", function onLoad(evt) {
                        var args;

                        if (evt.type === "load" || this.readyState === "loaded" || this.readyState === "complete") {
                            args = anonymouses.pop();

                            if (args) {
                                ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure);
                            } else {
                                ready({}, path, [], null);
                            }

                            off(script, useOnLoad ? "load" : "readystatechange", onLoad);
                        }
                    });

                    script.setAttribute("type", "text/javascript");
                    script.setAttribute("src", path);

                    head.insertBefore(script, head.firstChild);
                },
                "anonymous": function (args) {
                    anonymouses.push(args);
                }
            });

            each(scripts, function () {
                var main = this.getAttribute("data-main");

                function pull() {
                    depend(implicitExtension(main), function (path) {
                        lookup(defaults, "fetch")({}, path, ready);
                    });
                }

                if (main) {
                    if (this.getAttribute("data-defer") === "yes") {
                        on(global, useDOMContentLoaded ? "DOMContentLoaded" : "load", pull);
                    } else {
                        pull();
                    }
                }
            });

            if (!getModule("jquery", defaults) && jQuery) {
                addModule("jquery", jQuery);
            }
        }(global.document));
    }
}());
<commit_msg>Removed "empty" as it is not used<commit_after>/*
 *  Modular - JavaScript AMD Framework
 *  Copyright (c) 2012 http://ovms.co. All Rights Reserved.
 *
 *  ====
 *
 *  This file is part of Modular.
 *
 *  Modular is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Modular is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Modular.  If not, see <http://www.gnu.org/licenses/>.
 */

/*global define, require */

(function () {
    "use strict";

    function each(obj, callback) {
        var key,
            length;

        if (!obj) {
            return;
        }

        if (obj.hasOwnProperty("length")) {
            for (key = 0, length = obj.length; key < length; key += 1) { // Keep JSLint happy with "+= 1"
                if (callback.call(obj[key], obj[key], key) === false) {
                    break;
                }
            }
        } else {
            for (key in obj) {
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        }
    }

    // For Closure compiler name-munging while keeping JSLint happy
    function lookup(obj, name) {
        return obj[name];
    }

    var global = new [Function][0]("return this;")(), // Keep JSLint happy
        defaults = {
            "baseUrl": "",
            "paths": {},
            "pathFilter": function (path) {
                return path;
            },
            "versions": {},
            "versionFilter": function (stack, path, version) {
                var val = stack[0];

                if (path === "jquery" && version) {
                    val = null;

                    each(stack, function () {
                        if (lookup(this(), "jquery") === version) {
                            val = this;

                            return false;
                        }
                    });
                }

                return {
                    val: val
                };
            },
            "fetch": function (config, path, ready) {},
            "anonymous": function (args) {}
        },
        pendings = {},
        modules = {};

    function extend(target) {
        each([].slice.call(arguments, 1), function () {
            each(this, function (val, key) {
                target[key] = val;
            });
        });

        return target;
    }

    function getType(obj) {
        return {}.toString.call(obj).match(/\[object ([\s\S]*)\]/)[1];
    }

    function isString(str) {
        return typeof str === "string" || getType(str) === "String";
    }

    function isPlainObject(obj) {
        return getType(obj) === "Object";
    }

    function isArray(str) {
        return getType(str) === "Array";
    }

    function isFunction(str) {
        return getType(str) === "Function";
    }

    function getBasePath(path) {
        path = path.replace(/[^\/]+$/, "");

        if (path.charAt(path.length - 1) !== "/") {
            path += "/";
        }

        return path;
    }

    function implicitExtension(path) {
        if (path.substr(path.length - 3) !== ".js") {
            path += ".js";
        }

        return path;
    }

    function makePath(basePath, currentPath, path, config) {
        var previousPath = "",
            components = lookup(config, "pathFilter")(path).split("/");

        each(lookup(config, "paths"), function (to, from) {
            if (components[0] === from) {
                components[0] = to;
            }
        });

        path = components.join("/");

        path = getBasePath(/^\.\.?\//.test(path) ? currentPath : basePath) + path;

        path = path.replace(/\/\.\//g, "/"); // Resolve same-directory symbols

        // Resolve parent-directory symbols
        while (previousPath !== path) {
            previousPath = path;
            path = path.replace(/[^\/]*\/\.\.\//, "");
        }

        return implicitExtension(path);
    }

    function parse(arg1, arg2, arg3, arg4) {
        var config,
            path,
            dependencies,
            closure;

        if (isPlainObject(arg1)) {
            config = arg1;
        } else if (isString(arg1)) {
            path = arg1;
        } else if (isArray(arg1)) {
            dependencies = arg1;
        } else if (isFunction(arg1)) {
            closure = arg1;
        }

        if (isString(arg2)) {
            path = arg2;
        } else if (isArray(arg2)) {
            dependencies = arg2;
        } else if (isFunction(arg2)) {
            closure = arg2;
        }

        if (isArray(arg3)) {
            dependencies = arg3;
        } else if (isFunction(arg3)) {
            closure = arg3;
        }

        if (isFunction(arg4)) {
            closure = arg4;
        }

        if (config && !path && !dependencies && !closure) {
            closure = config;
            config = null;
        }

        return {
            config: config || {},
            path: path || null,
            dependencies: dependencies || [],
            closure: closure || function () {}
        };
    }

    function getModule(path, config) {
        var result = null;

        if (!modules.hasOwnProperty(path)) {
            return null;
        }

        return lookup(config, "versionFilter")(modules[path], path, lookup(config, "versions")[path]);
    }

    function addModule(path, val) {
        if (!modules[path]) {
            modules[path] = [];
        }

        modules[path].push(val);
    }

    function depend(path, fetch, recheck) {
        if (!pendings[path]) {
            pendings[path] = [];

            fetch(path);
        }

        if (recheck) {
            pendings[path].push(recheck);
        }
    }

    function ready(config, path, dependencies, closure, options) {
        var fetched = false;

        function processDependents(moduleValue) {
            var callbacks;

            // Caching may be explicitly disabled, eg. for scoped requires (which would otherwise
            //  overwrite their container module)
            if (options.cache !== false) {
                addModule(path, moduleValue);

                if (pendings[path]) {
                    callbacks = pendings[path];

                    delete pendings[path];

                    each(callbacks, function (dependencyLoaded) {
                        dependencyLoaded();
                    });
                }
            }
        }

        function checkDependencies() {
            var allResolved = true,
                moduleValue = null,
                args = [];

            each(dependencies, function (dependencyPath) {
                var fullPath = makePath(lookup(config, "baseUrl"), path, dependencyPath, config),
                    result;

                // Scoped require support
                if (dependencyPath === "require") {
                    args.push(function (arg1, arg2, arg3, arg4) {
                        var args = parse(arg1, arg2, arg3, arg4);

                        ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure, {
                            cache: false
                        });
                    });
                // Exports support
                } else if (dependencyPath === "exports") {
                    moduleValue = {};
                    args.push(moduleValue);
                } else {
                    result = getModule(dependencyPath, config) || getModule(fullPath, config);

                    if (result) {
                        args.push(result.val);
                    } else {
                        if (!fetched) {
                            depend(fullPath, function (path) {
                                lookup(config, "fetch")(config, path, ready);
                            }, checkDependencies);
                        }

                        allResolved = false;
                    }
                }
            });

            fetched = true;

            if (allResolved) {
                moduleValue = (isFunction(closure) ? closure.apply(global, args) : closure) || moduleValue;

                processDependents(moduleValue);
            }
        }

        options = options || {};

        checkDependencies();
    }

    function require(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4);

        ready(extend({}, defaults, args.config), args.path || lookup(args.config, "baseUrl"), args.dependencies, args.closure);
    }

    function define(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4),
            config = extend({}, defaults, args.config);

        if (args.path) {
            ready(config, args.path, args.dependencies, args.closure);
        } else {
            lookup(config, "anonymous")(args);
        }
    }

    extend(require, {
        "config": function (config) {
            extend(defaults, config);
        },
        "onError": function (msg) {
            throw new Error(msg);
        }
    });

    extend(define, {
        // Publish support for the AMD pattern
        "amd": {
            "jQuery": true
        }
    });

    // Exports
    extend(global, {
        "require": require,
        "requirejs": require,
        "define": define
    });

    // Browser environment support
    if (global.document) {
        (function (document) {
            var scripts = document.getElementsByTagName("script"),
                head = scripts[0].parentNode,
                on = head.addEventListener ? function (node, type, callback) {
                    node.addEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.attachEvent("on" + type, callback);
                },
                off = head.removeEventListener ? function (node, type, callback) {
                    node.removeEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.detachEvent("on" + type, callback);
                },
                useOnLoad = head.addEventListener && (!head.attachEvent || global.opera),
                useDOMContentLoaded = {}.hasOwnProperty.call(global, "DOMContentLoaded"),
                jQuery = lookup(global, "jQuery"),
                anonymouses = [];

            extend(defaults, {
                "baseUrl": global.location.pathname,
                // Overridable - called when a module needs to be loaded
                "fetch": function (config, path, ready) {
                    var script = document.createElement("script");

                    on(script, useOnLoad ? "load" : "readystatechange", function onLoad(evt) {
                        var args;

                        if (evt.type === "load" || this.readyState === "loaded" || this.readyState === "complete") {
                            args = anonymouses.pop();

                            if (args) {
                                ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure);
                            } else {
                                ready({}, path, [], null);
                            }

                            off(script, useOnLoad ? "load" : "readystatechange", onLoad);
                        }
                    });

                    script.setAttribute("type", "text/javascript");
                    script.setAttribute("src", path);

                    head.insertBefore(script, head.firstChild);
                },
                "anonymous": function (args) {
                    anonymouses.push(args);
                }
            });

            each(scripts, function () {
                var main = this.getAttribute("data-main");

                function pull() {
                    depend(implicitExtension(main), function (path) {
                        lookup(defaults, "fetch")({}, path, ready);
                    });
                }

                if (main) {
                    if (this.getAttribute("data-defer") === "yes") {
                        on(global, useDOMContentLoaded ? "DOMContentLoaded" : "load", pull);
                    } else {
                        pull();
                    }
                }
            });

            if (!getModule("jquery", defaults) && jQuery) {
                addModule("jquery", jQuery);
            }
        }(global.document));
    }
}());
<|endoftext|>


<commit_before>/*
 *  Modular - JavaScript AMD framework
 *  Copyright (c) 2012 http://ovms.co. All Rights Reserved.
 *
 *  ====
 *
 *  This file is part of Modular.
 *
 *  Modular is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Modular is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Modular.  If not, see <http://www.gnu.org/licenses/>.
 */

/*global define, require */

(function () {
    "use strict";

    var global = new Function("return this;")(),
        defaults = {
            "baseUrl": "",
            "fetch": function (path, ready) {},
            "anonymous": function (args) {}
        },
        pendings = {},
        modules = {};

    function each(obj, callback) {
        var key,
            length;

        if (!obj) {
            return;
        }

        if (obj.hasOwnProperty("length")) {
            for (key = 0, length = obj.length; key < length; key += 1) { // Keep JSLint happy with "+= 1"
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        } else {
            for (key in obj) {
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        }
    }

    function extend(target) {
        each([].slice.call(arguments, 1), function () {
            each(this, function (val, key) {
                target[key] = val;
            });
        });

        return target;
    }

    function getType(obj) {
        return {}.toString.call(obj).match(/\[object ([\s\S]*)\]/)[1];
    }

    function isString(str) {
        return typeof str === "string" || getType(str) === "String";
    }

    function isPlainObject(obj) {
        return getType(obj) === "Object";
    }

    function isArray(str) {
        return getType(str) === "Array";
    }

    function isFunction(str) {
        return getType(str) === "Function";
    }

    function getBasePath(path) {
        path = path.replace(/[^\/]+$/, "");

        if (path.charAt(path.length - 1) !== "/") {
            path += "/";
        }

        return path;
    }

    function implicitExtension(path) {
        if (path.substr(path.length - 3) !== ".js") {
            path += ".js";
        }

        return path;
    }

    function makePath(basePath, currentPath, path, pathMappings) {
        var previousPath = "",
            components = path.split("/");

        each(pathMappings || {}, function (to, from) {
            if (components[0] === from) {
                components[0] = to;
            }
        });

        path = components.join("/");

        path = getBasePath(/^\.\.?\//.test(path) ? currentPath : basePath) + path;

        path = path.replace(/\/\.\//g, "/"); // Resolve same-directory symbols

        // Resolve parent-directory symbols
        while (previousPath !== path) {
            previousPath = path;
            path = path.replace(/[^\/]*\/\.\.\//, "");
        }

        return implicitExtension(path);
    }

    function parse(arg1, arg2, arg3, arg4) {
        var config,
            path,
            dependencies,
            closure;

        if (isPlainObject(arg1)) {
            config = arg1;
        } else if (isString(arg1)) {
            path = arg1;
        } else if (isArray(arg1)) {
            dependencies = arg1;
        } else if (isFunction(arg1)) {
            closure = arg1;
        }

        if (isString(arg2)) {
            path = arg2;
        } else if (isArray(arg2)) {
            dependencies = arg2;
        } else if (isFunction(arg2)) {
            closure = arg2;
        }

        if (isArray(arg3)) {
            dependencies = arg3;
        } else if (isFunction(arg3)) {
            closure = arg3;
        }

        if (isFunction(arg4)) {
            closure = arg4;
        }

        if (config && !path && !dependencies && !closure) {
            closure = config;
            config = null;
        }

        return {
            config: config || {},
            path: path || null,
            dependencies: dependencies || [],
            closure: closure || function () {}
        };
    }

    function findModule(names) {
        var result = null;

        each(names, function (name) {
            if (modules.hasOwnProperty(name)) {
                result = name;

                return false;
            }
        });

        return result;
    }

    function getModule(names) {
        var name = findModule(names);

        return name ? modules[name] : null;
    }

    function depend(path, fetch, recheck) {
        if (!pendings[path]) {
            pendings[path] = [];

            fetch(path);
        }

        if (recheck) {
            pendings[path].push(recheck);
        }
    }

    function ready(config, path, dependencies, closure, options) {
        var fetched = false;

        function allDependenciesLoaded() {
            var moduleValue = null;

            function processDependents() {
                var callbacks;

                // Caching may be explicitly disabled, eg. for scoped requires (which would otherwise
                //  overwrite their container module)
                if (options.cache !== false) {
                    modules[path] = moduleValue;
                }

                if (pendings[path]) {
                    callbacks = pendings[path];

                    delete pendings[path];

                    each(callbacks, function (dependencyLoaded) {
                        dependencyLoaded();
                    });
                }
            }

            function evaluateModule() {
                var args = [];

                each(dependencies, function (dependencyPath) {
                    var fullPath = makePath(config.baseUrl, path, dependencyPath, config.paths);

                    // Scoped require support
                    if (dependencyPath === "require") {
                        args.push(function (arg1, arg2, arg3, arg4) {
                            var args = parse(arg1, arg2, arg3, arg4);

                            ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure, {
                                cache: false
                            });
                        });
                    } else {
                        args.push(getModule([dependencyPath, fullPath]));
                    }
                });

                return isFunction(closure) ? closure.apply(global, args) : closure;
            }

            moduleValue = evaluateModule();

            // Modules may have no path (eg. an anonymous require(...))
            processDependents();
        }

        function checkDependencies() {
            var allResolved = true;

            each(dependencies, function (dependencyPath) {
                var fullPath = makePath(config.baseUrl, path, dependencyPath, config.paths);

                if (dependencyPath !== "require" && !findModule([dependencyPath, fullPath])) {
                    if (!fetched) {
                        depend(fullPath, function (path) {
                            config.fetch(path, ready);
                        }, checkDependencies);
                    }

                    allResolved = false;
                }
            });

            fetched = true;

            if (allResolved) {
                allDependenciesLoaded();
            }
        }

        options = options || {};

        checkDependencies();
    }

    function require(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4);

        ready(extend({}, defaults, args.config), args.path || args.config.baseUrl, args.dependencies, args.closure);
    }

    function define(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4),
            config = extend({}, defaults, args.config);

        if (args.path) {
            ready(config, args.path, args.dependencies, args.closure);
        } else {
            config.anonymous(args);
        }
    }

    extend(require, {
        "config": function (config) {
            extend(defaults, config);
        },
        "onError": function (msg) {
            throw new Error(msg);
        }
    });

    extend(define, {
        // Publish support for the AMD pattern
        "amd": {
            "jQuery": true
        }
    });

    // Exports
    extend(global, {
        "require": require,
        "requirejs": require,
        "define": define
    });

    // Browser environment support
    if (global.document) {
        (function () {
            var head = global.document.getElementsByTagName("head")[0],
                on = head.addEventListener ? function (node, type, callback) {
                    node.addEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.attachEvent("on" + type, callback);
                },
                off = head.removeEventListener ? function (node, type, callback) {
                    node.removeEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.detachEvent("on" + type, callback);
                },
                useOnLoad = head.addEventListener,
                useDOMContentLoaded = {}.hasOwnProperty.call(global, "DOMContentLoaded"),
                anonymouses = [];

            extend(defaults, {
                "baseUrl": global.location.pathname,
                // Overridable - called when a module needs to be loaded
                "fetch": function (path, ready) {
                    var script = global.document.createElement("script"),
                        config = this;

                    on(script, useOnLoad ? "load" : "readystatechange", function onLoad(evt) {
                        var args;

                        if (evt.type === "load" || this.readyState === "loaded" || this.readyState === "complete") {
                            args = anonymouses.pop();

                            if (args) {
                                ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure);
                            } else {
                                ready({}, path, [], null);
                            }
                        }

                        off(script, useOnLoad ? "load" : "readystatechange", onLoad);
                    });

                    script.setAttribute("type", "text/javascript");
                    script.setAttribute("src", path);

                    head.insertBefore(script, head.firstChild);
                },
                "anonymous": function (args) {
                    anonymouses.push(args);
                }
            });

            each(global.document.getElementsByTagName("script"), function () {
                var main = this.getAttribute("data-main");

                function pull() {
                    depend(implicitExtension(main), function (path) {
                        defaults.fetch(path, ready);
                    });
                }

                if (main) {
                    if (this.getAttribute("data-defer") === "yes") {
                        on(global, useDOMContentLoaded ? "DOMContentLoaded" : "load", pull);
                    } else {
                        pull();
                    }
                }
            });
        }());
    }
}());
<commit_msg>Moved off() call inside conditional in fetch so it allows multiple readystates<commit_after>/*
 *  Modular - JavaScript AMD framework
 *  Copyright (c) 2012 http://ovms.co. All Rights Reserved.
 *
 *  ====
 *
 *  This file is part of Modular.
 *
 *  Modular is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Modular is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Modular.  If not, see <http://www.gnu.org/licenses/>.
 */

/*global define, require */

(function () {
    "use strict";

    var global = new Function("return this;")(),
        defaults = {
            "baseUrl": "",
            "fetch": function (path, ready) {},
            "anonymous": function (args) {}
        },
        pendings = {},
        modules = {};

    function each(obj, callback) {
        var key,
            length;

        if (!obj) {
            return;
        }

        if (obj.hasOwnProperty("length")) {
            for (key = 0, length = obj.length; key < length; key += 1) { // Keep JSLint happy with "+= 1"
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        } else {
            for (key in obj) {
                if (obj.hasOwnProperty(key)) {
                    if (callback.call(obj[key], obj[key], key) === false) {
                        break;
                    }
                }
            }
        }
    }

    function extend(target) {
        each([].slice.call(arguments, 1), function () {
            each(this, function (val, key) {
                target[key] = val;
            });
        });

        return target;
    }

    function getType(obj) {
        return {}.toString.call(obj).match(/\[object ([\s\S]*)\]/)[1];
    }

    function isString(str) {
        return typeof str === "string" || getType(str) === "String";
    }

    function isPlainObject(obj) {
        return getType(obj) === "Object";
    }

    function isArray(str) {
        return getType(str) === "Array";
    }

    function isFunction(str) {
        return getType(str) === "Function";
    }

    function getBasePath(path) {
        path = path.replace(/[^\/]+$/, "");

        if (path.charAt(path.length - 1) !== "/") {
            path += "/";
        }

        return path;
    }

    function implicitExtension(path) {
        if (path.substr(path.length - 3) !== ".js") {
            path += ".js";
        }

        return path;
    }

    function makePath(basePath, currentPath, path, pathMappings) {
        var previousPath = "",
            components = path.split("/");

        each(pathMappings || {}, function (to, from) {
            if (components[0] === from) {
                components[0] = to;
            }
        });

        path = components.join("/");

        path = getBasePath(/^\.\.?\//.test(path) ? currentPath : basePath) + path;

        path = path.replace(/\/\.\//g, "/"); // Resolve same-directory symbols

        // Resolve parent-directory symbols
        while (previousPath !== path) {
            previousPath = path;
            path = path.replace(/[^\/]*\/\.\.\//, "");
        }

        return implicitExtension(path);
    }

    function parse(arg1, arg2, arg3, arg4) {
        var config,
            path,
            dependencies,
            closure;

        if (isPlainObject(arg1)) {
            config = arg1;
        } else if (isString(arg1)) {
            path = arg1;
        } else if (isArray(arg1)) {
            dependencies = arg1;
        } else if (isFunction(arg1)) {
            closure = arg1;
        }

        if (isString(arg2)) {
            path = arg2;
        } else if (isArray(arg2)) {
            dependencies = arg2;
        } else if (isFunction(arg2)) {
            closure = arg2;
        }

        if (isArray(arg3)) {
            dependencies = arg3;
        } else if (isFunction(arg3)) {
            closure = arg3;
        }

        if (isFunction(arg4)) {
            closure = arg4;
        }

        if (config && !path && !dependencies && !closure) {
            closure = config;
            config = null;
        }

        return {
            config: config || {},
            path: path || null,
            dependencies: dependencies || [],
            closure: closure || function () {}
        };
    }

    function findModule(names) {
        var result = null;

        each(names, function (name) {
            if (modules.hasOwnProperty(name)) {
                result = name;

                return false;
            }
        });

        return result;
    }

    function getModule(names) {
        var name = findModule(names);

        return name ? modules[name] : null;
    }

    function depend(path, fetch, recheck) {
        if (!pendings[path]) {
            pendings[path] = [];

            fetch(path);
        }

        if (recheck) {
            pendings[path].push(recheck);
        }
    }

    function ready(config, path, dependencies, closure, options) {
        var fetched = false;

        function allDependenciesLoaded() {
            var moduleValue = null;

            function processDependents() {
                var callbacks;

                // Caching may be explicitly disabled, eg. for scoped requires (which would otherwise
                //  overwrite their container module)
                if (options.cache !== false) {
                    modules[path] = moduleValue;
                }

                if (pendings[path]) {
                    callbacks = pendings[path];

                    delete pendings[path];

                    each(callbacks, function (dependencyLoaded) {
                        dependencyLoaded();
                    });
                }
            }

            function evaluateModule() {
                var args = [];

                each(dependencies, function (dependencyPath) {
                    var fullPath = makePath(config.baseUrl, path, dependencyPath, config.paths);

                    // Scoped require support
                    if (dependencyPath === "require") {
                        args.push(function (arg1, arg2, arg3, arg4) {
                            var args = parse(arg1, arg2, arg3, arg4);

                            ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure, {
                                cache: false
                            });
                        });
                    } else {
                        args.push(getModule([dependencyPath, fullPath]));
                    }
                });

                return isFunction(closure) ? closure.apply(global, args) : closure;
            }

            moduleValue = evaluateModule();

            // Modules may have no path (eg. an anonymous require(...))
            processDependents();
        }

        function checkDependencies() {
            var allResolved = true;

            each(dependencies, function (dependencyPath) {
                var fullPath = makePath(config.baseUrl, path, dependencyPath, config.paths);

                if (dependencyPath !== "require" && !findModule([dependencyPath, fullPath])) {
                    if (!fetched) {
                        depend(fullPath, function (path) {
                            config.fetch(path, ready);
                        }, checkDependencies);
                    }

                    allResolved = false;
                }
            });

            fetched = true;

            if (allResolved) {
                allDependenciesLoaded();
            }
        }

        options = options || {};

        checkDependencies();
    }

    function require(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4);

        ready(extend({}, defaults, args.config), args.path || args.config.baseUrl, args.dependencies, args.closure);
    }

    function define(arg1, arg2, arg3, arg4) {
        var args = parse(arg1, arg2, arg3, arg4),
            config = extend({}, defaults, args.config);

        if (args.path) {
            ready(config, args.path, args.dependencies, args.closure);
        } else {
            config.anonymous(args);
        }
    }

    extend(require, {
        "config": function (config) {
            extend(defaults, config);
        },
        "onError": function (msg) {
            throw new Error(msg);
        }
    });

    extend(define, {
        // Publish support for the AMD pattern
        "amd": {
            "jQuery": true
        }
    });

    // Exports
    extend(global, {
        "require": require,
        "requirejs": require,
        "define": define
    });

    // Browser environment support
    if (global.document) {
        (function () {
            var head = global.document.getElementsByTagName("head")[0],
                on = head.addEventListener ? function (node, type, callback) {
                    node.addEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.attachEvent("on" + type, callback);
                },
                off = head.removeEventListener ? function (node, type, callback) {
                    node.removeEventListener(type, callback, false);
                } : function (node, type, callback) {
                    node.detachEvent("on" + type, callback);
                },
                useOnLoad = head.addEventListener && (!head.attachEvent || global.opera),
                useDOMContentLoaded = {}.hasOwnProperty.call(global, "DOMContentLoaded"),
                anonymouses = [];

            extend(defaults, {
                "baseUrl": global.location.pathname,
                // Overridable - called when a module needs to be loaded
                "fetch": function (path, ready) {
                    var script = global.document.createElement("script"),
                        config = this;

                    on(script, useOnLoad ? "load" : "readystatechange", function onLoad(evt) {
                        var args;

                        if (evt.type === "load" || this.readyState === "loaded" || this.readyState === "complete") {
                            args = anonymouses.pop();

                            if (args) {
                                ready(extend({}, config, args.config), args.path || path, args.dependencies, args.closure);
                            } else {
                                ready({}, path, [], null);
                            }

                            off(script, useOnLoad ? "load" : "readystatechange", onLoad);
                        }
                    });

                    script.setAttribute("type", "text/javascript");
                    script.setAttribute("src", path);

                    head.insertBefore(script, head.firstChild);
                },
                "anonymous": function (args) {
                    anonymouses.push(args);
                }
            });

            each(global.document.getElementsByTagName("script"), function () {
                var main = this.getAttribute("data-main");

                function pull() {
                    depend(implicitExtension(main), function (path) {
                        defaults.fetch(path, ready);
                    });
                }

                if (main) {
                    if (this.getAttribute("data-defer") === "yes") {
                        on(global, useDOMContentLoaded ? "DOMContentLoaded" : "load", pull);
                    } else {
                        pull();
                    }
                }
            });
        }());
    }
}());
<|endoftext|>


<commit_before>define(function(require, exports, module) {
    main.consumes = [
        "c9", "Plugin", "editors", "dialog.error",
        "terminal.monitor.message_view", "tabManager", "error_handler",
        "proc"
    ];
    main.provides = ["terminal.monitor"];
    return main;

    function main(options, imports, register) {
        var BASHBIN = options.bashBin ||  "/bin/bash";

        var c9 = imports.c9;
        var Plugin = imports.Plugin;
        var editors = imports.editors;
        var messageView = imports["terminal.monitor.message_view"];
        var tabManager = imports.tabManager;
        var errorHandler = imports.error_handler;
        var proc = imports.proc;

        var MessageHandler = require("./message_handler");
        var messageMatchers = require("./message_matchers")(c9);

        var plugin = new Plugin("Ajax.org", main.consumes);
        var messageHandler = new MessageHandler(messageMatchers.matchers, messageView);

        var loaded = false;
        function load() {
            if (loaded) return false;
            loaded = true;

            messageView.on("action", function(cmd, message) {
                console.log(cmd);
                proc.execFile(BASHBIN, {
                    args: ["--login", "-c", cmd]
                }, function() {
                    messageHandler.hide(message);
                });
            }, plugin);

            editors.on("create", function(e) {
                if (!e.editor || e.editor.type !== "terminal" && e.editor.type !== "output")
                    return;

                e.editor.on("documentLoad", onDocumentLoad);
            }, plugin);

            function onDocumentLoad(e) {
                var session = e.doc.getSession();
                session.once("terminalReady", setupTerminalMessageHandler);
            }
        }

        function setupTerminalMessageHandler(session) {
            var terminal = session.terminal;
            var seenUpTo = 0;
            var hasResizeCompleted = false;

            function handleMessage(message) {
                var tab = session.tab;
                if (tab.isActive() && tabManager.focussedTab === tab) {
                    messageHandler.handleMessage(message, tab);
                }
            }

            terminal.on("newline", function(e) {
                var y = e.y;
                var linesIndex = y + e.ybase - 1;

                if (e.y >= e.rows)
                    return; // can happen during resize
                if (!Array.isArray(e.lines[linesIndex])) {
                    errorHandler.reportError(new Error("Can not access line item in lines array"), {
                        y: e.y,
                        ybase: e.ybase,
                        linesCnt: e.lines ? e.lines.length : undefined,
                        rows: e.rows
                    }, ["terminal.monitor"]);
                    return;
                }

                var line = e.lines[linesIndex].map(function(character) {
                    return character && character[1];
                }).join("");

                if (!hasResizeCompleted) {
                    if (line.length) {
                        seenUpTo = e.y;
                    }
                    return;
                }

                // There are cases where newline doesn't fire for a "rendered" newline.
                // Making sure that we check lines when we encounter these gaps.
                while (seenUpTo < y) {
                    seenUpTo++;
                    var tmpLinesIndex = seenUpTo + e.ybase - 1;
                    var tmpLine = e.lines[tmpLinesIndex].map(function(character) {
                        return character && character[1];
                    }).join("");
                    handleMessage(tmpLine);
                }

                if (y - 1 > seenUpTo) return;
                seenUpTo = y;

                handleMessage(line);
            });

            var resizeTimeout;
            terminal.on("resizeStart", function() {
                hasResizeCompleted = false;
                if (resizeTimeout) {
                    clearTimeout(resizeTimeout);
                }

                messageHandler.reposition(session.tab);

                resizeTimeout = setTimeout(function() {
                    resizeTimeout = null;
                    hasResizeCompleted = true;
                }, 1000);
            });
        }

        /***** Lifecycle *****/

        plugin.on("load", function() {
            load();
        });

        plugin.on("unload", function() {
             loaded = false;
        });

        plugin.freezePublicAPI({});

        /***** Register and define API *****/
        register(null, {
            "terminal.monitor": plugin
        });
    }
});
<commit_msg>remove console.log<commit_after>define(function(require, exports, module) {
    main.consumes = [
        "c9", "Plugin", "editors", "dialog.error",
        "terminal.monitor.message_view", "tabManager", "error_handler",
        "proc"
    ];
    main.provides = ["terminal.monitor"];
    return main;

    function main(options, imports, register) {
        var BASHBIN = options.bashBin ||  "/bin/bash";

        var c9 = imports.c9;
        var Plugin = imports.Plugin;
        var editors = imports.editors;
        var messageView = imports["terminal.monitor.message_view"];
        var tabManager = imports.tabManager;
        var errorHandler = imports.error_handler;
        var proc = imports.proc;

        var MessageHandler = require("./message_handler");
        var messageMatchers = require("./message_matchers")(c9);

        var plugin = new Plugin("Ajax.org", main.consumes);
        var messageHandler = new MessageHandler(messageMatchers.matchers, messageView);

        var loaded = false;
        function load() {
            if (loaded) return false;
            loaded = true;

            messageView.on("action", function(cmd, message) {
                proc.execFile(BASHBIN, {
                    args: ["--login", "-c", cmd]
                }, function() {
                    messageHandler.hide(message);
                });
            }, plugin);

            editors.on("create", function(e) {
                if (!e.editor || e.editor.type !== "terminal" && e.editor.type !== "output")
                    return;

                e.editor.on("documentLoad", onDocumentLoad);
            }, plugin);

            function onDocumentLoad(e) {
                var session = e.doc.getSession();
                session.once("terminalReady", setupTerminalMessageHandler);
            }
        }

        function setupTerminalMessageHandler(session) {
            var terminal = session.terminal;
            var seenUpTo = 0;
            var hasResizeCompleted = false;

            function handleMessage(message) {
                var tab = session.tab;
                if (tab.isActive() && tabManager.focussedTab === tab) {
                    messageHandler.handleMessage(message, tab);
                }
            }

            terminal.on("newline", function(e) {
                var y = e.y;
                var linesIndex = y + e.ybase - 1;

                if (e.y >= e.rows)
                    return; // can happen during resize
                if (!Array.isArray(e.lines[linesIndex])) {
                    errorHandler.reportError(new Error("Can not access line item in lines array"), {
                        y: e.y,
                        ybase: e.ybase,
                        linesCnt: e.lines ? e.lines.length : undefined,
                        rows: e.rows
                    }, ["terminal.monitor"]);
                    return;
                }

                var line = e.lines[linesIndex].map(function(character) {
                    return character && character[1];
                }).join("");

                if (!hasResizeCompleted) {
                    if (line.length) {
                        seenUpTo = e.y;
                    }
                    return;
                }

                // There are cases where newline doesn't fire for a "rendered" newline.
                // Making sure that we check lines when we encounter these gaps.
                while (seenUpTo < y) {
                    seenUpTo++;
                    var tmpLinesIndex = seenUpTo + e.ybase - 1;
                    var tmpLine = e.lines[tmpLinesIndex].map(function(character) {
                        return character && character[1];
                    }).join("");
                    handleMessage(tmpLine);
                }

                if (y - 1 > seenUpTo) return;
                seenUpTo = y;

                handleMessage(line);
            });

            var resizeTimeout;
            terminal.on("resizeStart", function() {
                hasResizeCompleted = false;
                if (resizeTimeout) {
                    clearTimeout(resizeTimeout);
                }

                messageHandler.reposition(session.tab);

                resizeTimeout = setTimeout(function() {
                    resizeTimeout = null;
                    hasResizeCompleted = true;
                }, 1000);
            });
        }

        /***** Lifecycle *****/

        plugin.on("load", function() {
            load();
        });

        plugin.on("unload", function() {
             loaded = false;
        });

        plugin.freezePublicAPI({});

        /***** Register and define API *****/
        register(null, {
            "terminal.monitor": plugin
        });
    }
});
<|endoftext|>


<commit_before>'use strict';

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const http = require('http');

const request = require('../common/request');
const common = require('../common/common');

let config;

if (process.env.NODE_ENV === "local") {
	config = require('../config/local.json');
} else {
	config = require('../config/prod.json');
}

app.use(bodyParser.json());

function makeInsuranceRequest(mlsID, mortID) {
	const body = {
		mlsID,
		mortID,
		services: {
			police: Math.random() > 0.5,
			water: Math.random() > 0.5,
			school: Math.random() > 0.5,
			sewage: Math.random() > 0.5
		}
	}
	const {
		domain,
		port
	} = config.hostnames.insinc;
	request.makeRequest(domain, port, '/insinc/municipal', 'POST', body);
}

function logAndRespond(request, response, endpoint, code, message) {
	common.logInfo("MUN", endpoint, request, code, message);
	return response.status(code).send(message);
}

app.post('/mun/appraisal', function(req, res) {
	if (!req.body.mlsID) {
		return logAndRespond(req, res, '/mun/appraisal', 400, 'Bad Request missing body parameter mlsID');
	}

	if (!req.body.mortID) {
		return logAndRespond(req, res, '/re/appraisal', 400, 'Bad Request missing body parameter mortID');
	}

	logAndRespond(req, res, '/mun/appraisal', 200, 'OK');

	makeInsuranceRequest(req.body.mlsID, req.body.mortID);
});

app.listen(config.hostnames.mun.port, function() {
	console.log(`MUN listening on port ${config.hostnames.mun.port}`);
});
<commit_msg>health route for mun<commit_after>'use strict';

const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const http = require('http');

const request = require('../common/request');
const common = require('../common/common');

let config;

if (process.env.NODE_ENV === "local") {
	config = require('../config/local.json');
} else {
	config = require('../config/prod.json');
}

app.use(bodyParser.json());

function makeInsuranceRequest(mlsID, mortID) {
	const body = {
		mlsID,
		mortID,
		services: {
			police: Math.random() > 0.5,
			water: Math.random() > 0.5,
			school: Math.random() > 0.5,
			sewage: Math.random() > 0.5
		}
	}
	const {
		domain,
		port
	} = config.hostnames.insinc;
	request.makeRequest(domain, port, '/insinc/municipal', 'POST', body);
}

function logAndRespond(request, response, endpoint, code, message) {
	common.logInfo("MUN", endpoint, request, code, message);
	return response.status(code).send(message);
}

app.get('/', function(req, res) {
	res.send('MUN Running');
});

app.post('/mun/appraisal', function(req, res) {
	if (!req.body.mlsID) {
		return logAndRespond(req, res, '/mun/appraisal', 400, 'Bad Request missing body parameter mlsID');
	}

	if (!req.body.mortID) {
		return logAndRespond(req, res, '/re/appraisal', 400, 'Bad Request missing body parameter mortID');
	}

	logAndRespond(req, res, '/mun/appraisal', 200, 'OK');

	makeInsuranceRequest(req.body.mlsID, req.body.mortID);
});

app.listen(config.hostnames.mun.port, function() {
	console.log(`MUN listening on port ${config.hostnames.mun.port}`);
});
<|endoftext|>


<commit_before>var fs = require('fs'),
    flow = require('flow'),
    glob = require('glob'),
    showdown = (new (require('showdown').Showdown.converter)).makeHtml,
    jqtpl = require('jqtpl'),
    path = require('path'),
    rimraf = require('rimraf'),
    util = require('util'),
    wrench = require('wrench');

module.exports = function(options, cb) {
	if(cb === undefined && typeof options === 'function') {
		cb = options;
		options = { };
	}

	var docdir = 'doc';
	options.input = options.input || docdir + '/input';
	options.data = options.data || docdir + '/data';
	options.output = options.output || docdir + '/output';

	var inputBasename = new RegExp('^' + escapeRegex(options.input) + '\/?(.*)\.(md|markdown)$');
	var dataName = new RegExp('^' + escapeRegex(options.data) + '\/?(.*)$');

	flow.exec(
		function() {
			rimraf(options.output, errcheck(this));
		}, function() {
			fs.mkdir(options.output, undefined, errcheck(this));
		}, function() {
			parseInputFiles(this.MULTI());
			copyDataFiles(this.MULTI());
		}, noArgs, cb
	);

	// Helpers
	function noArgs() {
		this();
	}

	function errcheck(continuation) {
		return function(err) {
			if(err) {
				cb(err);
			} else {
				var args = Array.prototype.slice.call(arguments, 1);
				continuation.call(this, args);
			}
		};
	}

	function errcheckMulti(argsArray) {
		var ok = true;
		argsArray.forEach(function(args) {
			if(ok && args[0] && args[0][0]) { ok = false; cb(args[0][0]); }
			//if(ok && args[0]) { ok = false; cb(args[0]); }
		});
		if(ok) { this.call(this, argsArray); }
	}

	function transform(inpath, outpath, cb, copyfn) {
		fs.stat(inpath, function(err, stat) {
			if(err) return cb(err);
			if(stat.isDirectory()) {
				fs.mkdir(outpath, undefined, errcheck(cb));
			} else {
				copyfn(inpath, outpath, cb);
			}
		});
	}

	function escapeRegex(text) {
		return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	}

	// Main logic
	function parseInputFiles(cb) {
		flow.exec(
			function() {
				fs.readFile(path.join(options.data, 'template.html'), 'utf8', errcheck(this));
			}, function(html) {
				jqtpl.template('doc', html[0]);
				glob(options.input + '/**/*.{md,markdown}', {}, errcheck(this));
			}, function(matches) {
				for(var i=0; i<matches[0].length; i++) {
					var match = matches[0][i];
					parseOneInputFile(match, this.MULTI());
				}
				this.MULTI()();
			}, errcheckMulti, cb
		);
	}

	function parseOneInputFile(input, cb) {
		var basename = input.match(inputBasename)[1].replace(/\//g, '.');
		var outfile = options.output + '/' + basename + '.html';
		transform(input, outfile, cb, function(inpath, outpath, cb) {
			flow.exec(
				function() {
					fs.readFile(input, 'utf8', errcheck(this));
				}, function(data) {
					data = showdown(data[0]);
					var title = data.match(/<h1(?:.*?)>(.*?)<\/h1>/)[1];
					data = jqtpl.tmpl('doc', { content: data, title: title });
					fs.writeFile(outpath, data, 'utf8', errcheck(this));
				}, cb
			);
		});
	}

	function copyDataFiles(cb) {
		flow.exec(
			function() {
				wrench.copyDirRecursive(options.data, options.output, errcheck(this));
			}, function() {
				fs.unlink(options.output + '/template.html', errcheck(this));
			}, cb
		);
	}

	function old_copyDataFiles(cb) {
		flow.exec(
			function() {
				glob(options.data + '/**/*', { }, errcheck(this));
			}, function(matches) {
				for(var i=0; i<matches[0].length; i++) {
					var match = matches[0][i];
					copyOneDataFile(match, this.MULTI());
				}
				this.MULTI()();
			}, errcheckMulti, cb
		);
	}

	function copyOneDataFile(input, callback) {
		if(input === options.data + '/template.html') return callback();
		var outfile = input.replace(dataName, options.output + '/$1');
		transform(input, outfile, callback, function(inpath, outpath, callback) {
			util.pump(fs.createReadStream(inpath), fs.createWriteStream(outpath), errcheck(callback));
		});
	}
};
<commit_msg>Removed old data copying code<commit_after>var fs = require('fs'),
    flow = require('flow'),
    glob = require('glob'),
    showdown = (new (require('showdown').Showdown.converter)).makeHtml,
    jqtpl = require('jqtpl'),
    path = require('path'),
    rimraf = require('rimraf'),
    util = require('util'),
    wrench = require('wrench');

module.exports = function(options, cb) {
	if(cb === undefined && typeof options === 'function') {
		cb = options;
		options = { };
	}

	var docdir = 'doc';
	options.input = options.input || docdir + '/input';
	options.data = options.data || docdir + '/data';
	options.output = options.output || docdir + '/output';

	var inputBasename = new RegExp('^' + escapeRegex(options.input) + '\/?(.*)\.(md|markdown)$');
	var dataName = new RegExp('^' + escapeRegex(options.data) + '\/?(.*)$');

	flow.exec(
		function() {
			rimraf(options.output, errcheck(this));
		}, function() {
			fs.mkdir(options.output, undefined, errcheck(this));
		}, function() {
			parseInputFiles(this.MULTI());
			copyDataFiles(this.MULTI());
		}, noArgs, cb
	);

	// Helpers
	function noArgs() {
		this();
	}

	function errcheck(continuation) {
		return function(err) {
			if(err) {
				cb(err);
			} else {
				var args = Array.prototype.slice.call(arguments, 1);
				continuation.call(this, args);
			}
		};
	}

	function errcheckMulti(argsArray) {
		var ok = true;
		argsArray.forEach(function(args) {
			if(ok && args[0] && args[0][0]) { ok = false; cb(args[0][0]); }
			//if(ok && args[0]) { ok = false; cb(args[0]); }
		});
		if(ok) { this.call(this, argsArray); }
	}

	function transform(inpath, outpath, cb, copyfn) {
		fs.stat(inpath, function(err, stat) {
			if(err) return cb(err);
			if(stat.isDirectory()) {
				fs.mkdir(outpath, undefined, errcheck(cb));
			} else {
				copyfn(inpath, outpath, cb);
			}
		});
	}

	function escapeRegex(text) {
		return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	}

	// Main logic
	function parseInputFiles(cb) {
		flow.exec(
			function() {
				fs.readFile(path.join(options.data, 'template.html'), 'utf8', errcheck(this));
			}, function(html) {
				jqtpl.template('doc', html[0]);
				glob(options.input + '/**/*.{md,markdown}', {}, errcheck(this));
			}, function(matches) {
				for(var i=0; i<matches[0].length; i++) {
					var match = matches[0][i];
					parseOneInputFile(match, this.MULTI());
				}
				this.MULTI()();
			}, errcheckMulti, cb
		);
	}

	function parseOneInputFile(input, cb) {
		var basename = input.match(inputBasename)[1].replace(/\//g, '.');
		var outfile = options.output + '/' + basename + '.html';
		transform(input, outfile, cb, function(inpath, outpath, cb) {
			flow.exec(
				function() {
					fs.readFile(input, 'utf8', errcheck(this));
				}, function(data) {
					data = showdown(data[0]);
					var title = data.match(/<h1(?:.*?)>(.*?)<\/h1>/)[1];
					data = jqtpl.tmpl('doc', { content: data, title: title });
					fs.writeFile(outpath, data, 'utf8', errcheck(this));
				}, cb
			);
		});
	}

	function copyDataFiles(cb) {
		flow.exec(
			function() {
				wrench.copyDirRecursive(options.data, options.output, errcheck(this));
			}, function() {
				fs.unlink(options.output + '/template.html', errcheck(this));
			}, cb
		);
	}
};
<|endoftext|>


<commit_before>//config
var plugin_dir = './plugins';

var system_type = 'graphite';
var config = {
    graphite_host : 'stats01-smc03',
    graphite_port : '2003',
    graphite_namespace : 'nervous.www02-smc03'
};

//deps
var fs = require('fs');
var axon_factory = require('axon_factory')( system_type, config );

//code

var load_plugins = function () {
    fs.readdir( plugin_dir, function( err, entries ) {
	    var dirs = [];
	    entries.forEach( function( entry ) {

		    var plugin_path = plugin_dir + '/' + entry;
		    fs.stat( plugin_path, function( err, stats ) {
			    if ( stats.isDirectory() ) {
				require( plugin_path )( axon_factory( entry ) );
			    }
			} );
	    } );

	}

	);
};

load_plugins();
<commit_msg>fixed dep<commit_after>//config
var plugin_dir = './plugins';

var system_type = 'graphite';
var config = {
    graphite_host : 'stats01-smc03',
    graphite_port : '2003',
    graphite_namespace : 'nervous.www02-smc03'
};

//deps
var fs = require('fs');
var axon_factory = require('./lib/axon_factory')( system_type, config );

//code

var load_plugins = function () {
    fs.readdir( plugin_dir, function( err, entries ) {
	    var dirs = [];
	    entries.forEach( function( entry ) {

		    var plugin_path = plugin_dir + '/' + entry;
		    fs.stat( plugin_path, function( err, stats ) {
			    if ( stats.isDirectory() ) {
				require( plugin_path )( axon_factory( entry ) );
			    }
			} );
	    } );

	}

	);
};

load_plugins();
<|endoftext|>


<commit_before>Openure = {
    allViews: [],
    currentView: "",
    listener: "",
    trackedViewsIDs: [],
    previousView: null,
    stackSize: 0,
    maxStackSize: 30,

    findViewsInArray: function (array) {
        //for x in array.len....
        //this.findViewsInView(region.currentView);
    },

    registerView: function (view) {
        if (view.cid && _.lastIndexOf(this.trackedViewsIDs, view.cid) == -1) {
            this.trackedViewsIDs.push(view.cid);
            this.allViews.push(view);
        }
    },

    findViewsInObject: function (obj) {
        this.stackSize++;
        if (this.stackSize < this.maxStackSize) {
            for (var prop in obj) {
                if (obj.nodeName) {
                    //this is an html element, and continuing will blow up
                    return;
                }

                if (obj[prop] instanceof Backbone.View) {
                    this.registerView(obj[prop]);
                    this.findViewsInObject(obj[prop]);
                } else if (obj[prop] instanceof Array) {
                    this.findViewsInArray(obj[prop]);
                } else if (obj[prop] instanceof Function) {
                    //skip
                } else if (obj[prop] instanceof Object) {
                    this.findViewsInObject(obj[prop]);
                }
            }
        }
        this.stackSize--;
    },

    applySelectedView: function () {
        clearInterval(this.listener);
        console.log("rock the view - " + this.currentView.cid);

        //Remove the current console when clicking a new one.
        if ($('#console').length) {
            this.previousView.el.removeChild($('#console')[0]);
        }

        //For now, close it by clicking the same view again.
        if (this.previousView && this.previousView.cid === this.currentView.cid) {
            this.previousView = null;
            return;
        }

        var jqconsole = document.createElement('div');

        jqconsole.style.cssText = 'width:' + 600 + 'px;z-index:99';
        jqconsole.id = "console";

        this.currentView.el.appendChild(jqconsole);

        // Creating the console.
        var header = 'Welcome to Openure in JQConsole!\n' +
            'The variable "view" is now in context\n' +
            '(here and in the chrome console.)\n' +
            'As is model, collection, and options.\n' +
            'Close this window with ctrl-q or ctrl-w.\n' +
            'Resize as needed.\n';
        this.jqconsole = $(jqconsole).jqconsole(header, 'JS> ');

        $(jqconsole).draggable().resizable();

        var that = this;
        // Abort prompt on Ctrl+Z.
        this.jqconsole.RegisterShortcut('Z', function () {
            that.jqconsole.AbortPrompt();
            handler();
        });

        // Move to line start Ctrl+A.
        this.jqconsole.RegisterShortcut('A', function () {
            that.jqconsole.MoveToStart();
            handler();
        });

        // Move to line end Ctrl+E.
        this.jqconsole.RegisterShortcut('E', function () {
            that.jqconsole.MoveToEnd();
            handler();
        });

        // Close console
        this.jqconsole.RegisterShortcut('W', function () {
            that.previousView.el.removeChild($('#console')[0]);
            that.previousView = null;
        });
        this.jqconsole.RegisterShortcut('Q', function () {
            that.previousView.el.removeChild($('#console')[0]);
            that.previousView = null;
        });

        this.jqconsole.RegisterMatching('{', '}', 'brace');
        this.jqconsole.RegisterMatching('(', ')', 'paran');
        this.jqconsole.RegisterMatching('[', ']', 'bracket');

        isObject = function (obj) {
            return obj === Object(obj);
        };

        // Handle a command.
        var handler = _.bind(function (command) {
            var result;
            if (command) {
                try {
                    result = window.eval(command);
                } catch (e) {
                    this.jqconsole.Write('ERROR: ' + e.message + '\n');
                }
                try {
                    if (isObject(result)) {
                        result = JSON.stringify(result, function (k, v) {
                            return (k === '$el' || k === 'el' || k === '_events' || k === '_listeners') ? undefined : v;
                        }, 2);
                    }
                } catch (e) {
                    if (e.message === 'Converting circular structure to JSON') {
                        this.jqconsole.Write('ERROR: ' + e.message + '\n');
                        this.jqconsole.Write('Please try the same command in the chrome console.\n');
                    }
                    else {
                        this.jqconsole.Write('ERROR: ' + e.message + '\n');
                    }
                }

                this.jqconsole.Write(result);
                this.jqconsole.Write('\n');
            }
            this.jqconsole.Prompt(true, handler, function (command) {
                // Continue line if can't compile the command.
                try {
                    Function(command);
                } catch (e) {
                    if (/[\[\{\(]$/.test(command)) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
                return false;
            });
        }, this);

        // Initiate the first prompt.
        handler();

        model = this.currentView.model;
        view = this.currentView;
        collection = this.currentView.collection;
        options = this.currentView.options;
        this.previousView = view;
    },

    go: function () {
        var backbone_app_key;
        var openureKey = $('openure_keys');
        if ((openureKey.length < 1 || openureKey.text() === "") && !openure_key) {
            console.log('No Openure keys are configured.  Go to the Chrome extensions page and add the key to the Openure options page.');
        }
        else {
            backbone_app_key = openureKey.text() || openure_key;
        }

        var that = this;

        console.log('Running Openure against global variable: ' + backbone_app_key);
        window.setInterval(function () {
            that.findViewsInObject(eval(backbone_app_key));

            _.each(that.allViews, function (view) {
                view.$el[0].addEventListener('click', _.bind(function (e) {
                    if (e.metaKey && e.shiftKey) {
                        var ownIt = _.bind(that.applySelectedView, that);

                        clearInterval(that.listener);
                        that.listener = setInterval(ownIt, 100);

                        e.preventDefault();
                        e.stopImmediatePropagation();
                        that.currentView = view;
                    }
                }, that), true);
            }, that);
        }, 2000);
    }
};

$(function () {
    Openure.go();
});
<commit_msg>Put console on bottom of screen<commit_after>Openure = {
    allViews: [],
    currentView: "",
    listener: "",
    trackedViewsIDs: [],
    previousView: null,
    stackSize: 0,
    maxStackSize: 30,

    findViewsInArray: function (array) {
        //for x in array.len....
        //this.findViewsInView(region.currentView);
    },

    registerView: function (view) {
        if (view.cid && _.lastIndexOf(this.trackedViewsIDs, view.cid) == -1) {
            this.trackedViewsIDs.push(view.cid);
            this.allViews.push(view);
        }
    },

    findViewsInObject: function (obj) {
        this.stackSize++;
        if (this.stackSize < this.maxStackSize) {
            for (var prop in obj) {
                if (obj.nodeName) {
                    //this is an html element, and continuing will blow up
                    return;
                }

                if (obj[prop] instanceof Backbone.View) {
                    this.registerView(obj[prop]);
                    this.findViewsInObject(obj[prop]);
                } else if (obj[prop] instanceof Array) {
                    this.findViewsInArray(obj[prop]);
                } else if (obj[prop] instanceof Function) {
                    //skip
                } else if (obj[prop] instanceof Object) {
                    this.findViewsInObject(obj[prop]);
                }
            }
        }
        this.stackSize--;
    },

    applySelectedView: function () {
        clearInterval(this.listener);
        console.log("rock the view - " + this.currentView.cid);

        //Remove the current console when clicking a new one.
        if ($('#console').length) {
            $('body')[0].removeChild($('#console')[0]);
        }

        //For now, close it by clicking the same view again.
        if (this.previousView && this.previousView.cid === this.currentView.cid) {
            this.previousView = null;
            return;
        }

        var jqconsole = document.createElement('div');

        jqconsole.style.cssText = 'width:' + 600 + 'px;z-index:99;bottom:0px';
        jqconsole.id = "console";

        $('body')[0].appendChild(jqconsole);

        // Creating the console.
        var header = 'Welcome to Openure in JQConsole!\n' +
            'The variable "view" is now in context\n' +
            '(here and in the chrome console.)\n' +
            'As is model, collection, and options.\n' +
            'Close this window with ctrl-q or ctrl-w.\n' +
            'Resize as needed.\n';
        this.jqconsole = $(jqconsole).jqconsole(header, 'JS> ');

        $(jqconsole).draggable().resizable();

        var that = this;
        // Abort prompt on Ctrl+Z.
        this.jqconsole.RegisterShortcut('Z', function () {
            that.jqconsole.AbortPrompt();
            handler();
        });

        // Move to line start Ctrl+A.
        this.jqconsole.RegisterShortcut('A', function () {
            that.jqconsole.MoveToStart();
            handler();
        });

        // Move to line end Ctrl+E.
        this.jqconsole.RegisterShortcut('E', function () {
            that.jqconsole.MoveToEnd();
            handler();
        });

        // Close console
        this.jqconsole.RegisterShortcut('W', function () {
            $('body')[0].removeChild($('#console')[0]);
            that.previousView = null;
        });
        this.jqconsole.RegisterShortcut('Q', function () {
            $('body')[0].removeChild($('#console')[0]);
            that.previousView = null;
        });

        this.jqconsole.RegisterMatching('{', '}', 'brace');
        this.jqconsole.RegisterMatching('(', ')', 'paran');
        this.jqconsole.RegisterMatching('[', ']', 'bracket');

        isObject = function (obj) {
            return obj === Object(obj);
        };

        // Handle a command.
        var handler = _.bind(function (command) {
            var result;
            if (command) {
                try {
                    result = window.eval(command);
                } catch (e) {
                    this.jqconsole.Write('ERROR: ' + e.message + '\n');
                }
                try {
                    if (isObject(result)) {
                        result = JSON.stringify(result, function (k, v) {
                            return (k === '$el' || k === 'el' || k === '_events' || k === '_listeners') ? undefined : v;
                        }, 2);
                    }
                } catch (e) {
                    if (e.message === 'Converting circular structure to JSON') {
                        this.jqconsole.Write('ERROR: ' + e.message + '\n');
                        this.jqconsole.Write('Please try the same command in the chrome console.\n');
                    }
                    else {
                        this.jqconsole.Write('ERROR: ' + e.message + '\n');
                    }
                }

                this.jqconsole.Write(result);
                this.jqconsole.Write('\n');
            }
            this.jqconsole.Prompt(true, handler, function (command) {
                // Continue line if can't compile the command.
                try {
                    Function(command);
                } catch (e) {
                    if (/[\[\{\(]$/.test(command)) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
                return false;
            });
        }, this);

        // Initiate the first prompt.
        handler();

        model = this.currentView.model;
        view = this.currentView;
        collection = this.currentView.collection;
        options = this.currentView.options;
        this.previousView = view;
    },

    go: function () {
        var backbone_app_key;
        var openureKey = $('openure_keys');
        if ((openureKey.length < 1 || openureKey.text() === "") && !openure_key) {
            console.log('No Openure keys are configured.  Go to the Chrome extensions page and add the key to the Openure options page.');
        }
        else {
            backbone_app_key = openureKey.text() || openure_key;
        }

        var that = this;

        console.log('Running Openure against global variable: ' + backbone_app_key);
        window.setInterval(function () {
            that.findViewsInObject(eval(backbone_app_key));

            _.each(that.allViews, function (view) {
                view.$el[0].addEventListener('click', _.bind(function (e) {
                    if (e.metaKey && e.shiftKey) {
                        var ownIt = _.bind(that.applySelectedView, that);

                        clearInterval(that.listener);
                        that.listener = setInterval(ownIt, 100);

                        e.preventDefault();
                        e.stopImmediatePropagation();
                        that.currentView = view;
                    }
                }, that), true);
            }, that);
        }, 2000);
    }
};

$(function () {
    Openure.go();
});
<|endoftext|>


<commit_before>/*global loadRules,saveRules,loadCloseSetting,saveCloseSetting*/
angular.module('options', []).controller('options', options);

function options($scope, $timeout) {
    $scope.matchCopy = {
        exact: 'exactly',
        base: 'up to the ?',
        hash: 'up to the #'
    };

    function reloadRules() {
        if($scope.rule) {
            postSaved();
        }
        $scope.rule = {match: 'hash'};
        loadRules((rules) => {
            $scope.rules = rules;
            $scope.$apply();
        });
    }

    function postSaved() {
        $scope.settingsSaved = true;
        $timeout(() => {
            $scope.settingsSaved = false;
        }, 3000);
        $scope.$apply();
    }

    $scope.saveRule = () => {
        delete $scope.editingRule;
        $scope.ruleSaved = false;
        $scope.rules[$scope.rule.url] = $scope.rule.match;
        saveRules($scope.rules, reloadRules);
    };

    $scope.deleteRule = (url) => {
        delete $scope.rules[url];
        saveRules($scope.rules, reloadRules);
    };

    $scope.editRule = (url, match) => {
        $scope.editingRule = url;
        $scope.rule = {
            url: url,
            match: match
        };
    };

    $scope.editing = (url) => url === $scope.editingRule;

    loadCloseSetting((close) => {
        $scope.close = close;
        $scope.$apply();
        watchClose();
    });

    function watchClose() {
        var ignoreFirst = true;
        $scope.$watch('close', (close) => {
            if(ignoreFirst) {
                ignoreFirst = false;
            } else {
                saveCloseSetting(close, postSaved);
            }
        });
    }

    reloadRules();
}
<commit_msg>actually disable save button when no url<commit_after>/*global loadRules,saveRules,loadCloseSetting,saveCloseSetting*/
angular.module('options', []).controller('options', options);

function options($scope, $timeout) {
    $scope.matchCopy = {
        exact: 'exactly',
        base: 'up to the ?',
        hash: 'up to the #'
    };

    function reloadRules() {
        if($scope.rule) {
            postSaved();
        }
        $scope.rule = {match: 'hash'};
        loadRules((rules) => {
            $scope.rules = rules;
            $scope.$apply();
        });
    }

    function postSaved() {
        $scope.settingsSaved = true;
        $timeout(() => {
            $scope.settingsSaved = false;
        }, 3000);
        $scope.$apply();
    }

    $scope.saveRule = () => {
        if($scope.rule.url) {
            delete $scope.editingRule;
            $scope.ruleSaved = false;
            $scope.rules[$scope.rule.url] = $scope.rule.match;
            saveRules($scope.rules, reloadRules);
        }
    };

    $scope.deleteRule = (url) => {
        delete $scope.rules[url];
        saveRules($scope.rules, reloadRules);
    };

    $scope.editRule = (url, match) => {
        $scope.editingRule = url;
        $scope.rule = {
            url: url,
            match: match
        };
    };

    $scope.editing = (url) => url === $scope.editingRule;

    loadCloseSetting((close) => {
        $scope.close = close;
        $scope.$apply();
        watchClose();
    });

    function watchClose() {
        var ignoreFirst = true;
        $scope.$watch('close', (close) => {
            if(ignoreFirst) {
                ignoreFirst = false;
            } else {
                saveCloseSetting(close, postSaved);
            }
        });
    }

    reloadRules();
}
<|endoftext|>


<commit_before>const Path = require('path');
const Package = require('./package.json');

module.exports = {
  cmd: 'mod-standard',
  version: Package.version,
  homepage: Package.homepage,
  bugs: Package.bugs.url,
  tagline: 'JavaScript Standard Modulus Style',
  eslintConfig: {
    configFile: Path.join(__dirname, '.eslintrc')
  }
};
<commit_msg>Return eslint with options object<commit_after>const Eslint = require('eslint');
const Path = require('path');
const Package = require('./package.json');

module.exports = {
  eslint: Eslint,
  cmd: 'mod-standard',
  version: Package.version,
  homepage: Package.homepage,
  bugs: Package.bugs.url,
  tagline: 'JavaScript Standard Modulus Style',
  eslintConfig: {
    configFile: Path.join(__dirname, '.eslintrc')
  }
};
<|endoftext|>