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AQ,QAAQ,UACZ,IAAK,SACD,MAAO,OACX,IAAK,QAED,OADA,EAAc,KAAK,SAAS,EAAK,KAAK,QAC/B,KACX,QACI,IAEI,OADA,IAAI,QAAQ,aACL,IAAI,UAAU,WACzB,CAAE,MAAO,GACL,OAAO,IACX,EAGX,EAhBuB,IAgBjB,MAAK,SAAU,GAClB,GAAK,EAIL,OAAO,IAAI,MAAM,EAAS,EAC9B,GACJ,IAGJ,OAAO,QAAU","file":"/npm/nokit@0.27.12/lib/kit.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/nokit@0.27.12/lib/kit.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst _ = require('lodash');\nconst fs = require('nofs');\nconst Promise = require('yaku');\nconst yutils = require('yaku/lib/utils');\nconst nodeUrl = require('url');\n\nconst kit = {};\n\n/**\n * Nokit extends all the functions of [nofs](https://github.com/ysmood/nofs)\n * and [`yaku/lib/utils`](https://github.com/ysmood/yaku#utils).\n * You can use it as same as nofs. For more info, see the doc:\n *\n * [Offline Documentation](?gotoDoc=nofs/readme.md)\n * @example\n * ```js\n * kit.readFile('test.txt', 'utf8').then((str) =>\n *     console.log(str)\n * );\n *\n * kit.outputFile('a.txt', 'test')\n * .then(() => kit.log('done'));\n *\n * kit.writeJSON('b.json', { a: 10 })\n * .then(() => kit.log('done'))\n *\n * kit.mkdirs('b.json', { a: 10 })\n * .then(() => kit.log('done'));\n * ```\n */\nconst Overview = 'overview'; // eslint-disable-line\n\n_.extend(kit, fs, yutils, {\n\n    /**\n     * The [lodash](https://lodash.com) lib.\n     * @type {Object}\n     * @example\n     * ```js\n     * kit._.map([1, 2, 3]);\n     * ```\n     */\n    _,\n\n    requireCache: {},\n\n    /**\n     * The browser helper. It helps you to live reload the page and log remotely.\n     * @static\n     * @param {Object} opts The options of the client, defaults:\n     * ```js\n     * {\n     *  host: '', // The host of the event source.\n     *  useJs: false // By default the function will return html string\n     * }\n     * ```\n     * @return {String} The code of client helper.\n     * @example\n     * When the client code is loaded on the browser, you can use\n     * the `nb.log` to log anything to server's terminal.\n     * The server will auto-format and log the information to the terminal.\n     * It's convinient for mobile development when remote debug is not possible.\n     * ```js\n     * // The nb is assigned to the \"window\" object.\n     * nb.log({ a: 10 });\n     * nb.log(10);\n     * nb.es.addEventListener('fileModified', () =>\n     *  console.log('file changed')\n     * );\n     * ```\n     */\n    browserHelper(opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        const helper = kit.browserHelper.cache ||\n            kit.require('./browserHelper', __dirname).toString();\n\n        const optsStr = JSON.stringify(_.defaults(opts, {\n            host: ''\n        }));\n\n        const js = `\n            if (!window.nokit) window.nokit = (${helper})(${optsStr});\\n\\\n        `;\n\n        if (opts.useJs) {\n            return js;\n        } else {\n            return `\n                \\n\\n<!-- Nokit Browser Helper -->\n                <script type=\"text/javascript\">\n                ${js}\n                </script>\\n\\n\\\n            `;\n        }\n    },\n\n    /**\n     * Generate styled string for terminal.\n     * It's disabled when `process.env.NODE_ENV == 'production'`.\n     * @example\n     * ```js\n     * let br = kit.require('brush');\n     * kit.log(br.red('error info'));\n     *\n     * // Disable color globally.\n     * br.isEnabled = false;\n     *\n     * // To see all the available brushes.\n     * kit.log(Object.keys(br));\n     * ```\n     */\n    brush: null,\n\n    /**\n     * A fast file cache helper. It uses hard link to cache files.\n     * @param  {Object} info Not optional.\n     * ```js\n     * {\n     *     // The first item is the key path, others are\n     *     // its dependencies.\n     *     deps: Array,\n     *\n     *     // The path of the output file.\n     *     // If it's undefined, depsCache will try to get cache.\n     *     dests: Array,\n     *\n     *     cacheDir: '.nokit'\n     * }\n     * ```\n     * @return {Promise} Resolve a info object.\n     * ```js\n     * {\n     *     isNewer: Boolean,\n     *\n     *     // { path: mtime }\n     *     deps: Object,\n     *\n     *     // { destPath: cachePath }\n     *     dests: Object,\n     *\n     *     cacheError: undefined || Error\n     * }\n     * ```\n     * @example\n     * ```js\n     * // Set cache\n     * kit.depsCache({\n     *  dests: ['index.css'],\n     *  deps: ['index.less', 'b.less', 'c.less']\n     * });\n     *\n     * // Get cache\n     * // You don't have to sepecify 'b.less', 'c.less'.\n     * kit.depsCache({ deps: ['index.less'] })\n     * .then((cache) => {\n     *     if (cache.isNewer) {\n     *         kit.log('cache is newer');\n     *         kit.log(cache.dests);\n     *     }\n     * });\n     * ```\n     */\n    depsCache(opts) {\n        let info;\n        _.defaults(opts, {\n            cacheDir: '.nokit'\n        });\n\n        if (kit.depsCache.jhash == null) {\n            kit.depsCache.jhash = new(kit.require('jhash').constructor);\n        }\n\n        const hashPath = function (path) {\n            const hash = kit.depsCache.jhash.hash(path, true) + '-' +\n                kit.path.basename(path);\n            path = kit.path.join(opts.cacheDir, hash);\n            return {\n                cache: path,\n                info: path + '.json'\n            };\n        };\n\n        const key = hashPath(opts.deps[0]);\n\n        if (opts.dests) {\n            info = {\n                dests: {},\n                deps: {}\n            };\n\n            const saveLink = (from, to) =>\n                kit.mkdirs(opts.cacheDir).then(() =>\n                    kit.link(from, to)\n                    .catch(function (err) {\n                        if (err.code !== 'EEXIST') {\n                            return Promise.reject(err);\n                        }\n                        return kit.unlink(to).then(() => kit.link(from, to));\n                    })\n                );\n\n            const saveInfo = infoPath =>\n                Promise.all(opts.deps.map(function (path, i) {\n                    if (i === 0) {\n                        return info.deps[path] = Date.now();\n                    }\n                    return kit.stat(path).catch(function () {}).then(function (stats) {\n                        if (!stats) {\n                            return;\n                        }\n                        return info.deps[path] = stats.mtime.getTime();\n                    });\n                })).then(() => kit.outputJson(infoPath, info)).then(() =>\n                    Promise.all(opts.deps.slice(1).map(dep => saveLink(infoPath, hashPath(dep).info)))\n                );\n\n            const saveContents = () =>\n                Promise.all(opts.dests.map(function (dest) {\n                    const hashed = hashPath(dest);\n                    info.dests[dest] = hashed.cache;\n                    return saveLink(dest, hashed.cache);\n                }));\n\n            return Promise.all([\n                saveContents(),\n                saveInfo(key.info)\n            ]);\n        } else {\n            info = {};\n            return kit.readJson(key.info)\n                .then(function (data) {\n                    info = data;\n                    return Promise.all(_(info.deps).keys().map(path =>\n                        kit.stat(path).then(stats =>\n                            // cache mtime             file mtime\n                            info.deps[path] >= stats.mtime.getTime())\n                    ).value());\n                }).then(function (latestList) {\n                    info.deps = _.keys(info.deps);\n                    return info.isNewer = _.every(latestList);\n                }).catch(err => info.cacheError = err)\n                .then(() => info);\n        }\n    },\n\n    /**\n     * Daemonize a program. Just a shortcut usage of `kit.spawn`.\n     * @param  {Object} opts Defaults:\n     * ```js\n     * {\n     *  bin: 'node',\n     *  args: ['app.js'],\n     *  stdout: 'stdout.log', // Can also be a fd\n     *  stderr: 'stderr.log'  // Can also be a fd\n     * }\n     * ```\n     * @return {Porcess} The daemonized process.\n     */\n    daemonize(opts) {\n        let errLog, outLog;\n        if (opts == null) {\n            opts = {};\n        }\n        _.defaults(opts, {\n            bin: 'node',\n            args: ['app.js'],\n            stdout: 'stdout.log',\n            stderr: 'stderr.log'\n        });\n\n        if (_.isString(opts.stdout)) {\n            outLog = kit.fs.openSync(opts.stdout, 'a');\n        }\n        if (_.isString(opts.stderr)) {\n            errLog = kit.fs.openSync(opts.stderr, 'a');\n        }\n\n        const p = kit.spawn(opts.bin, opts.args, {\n            detached: true,\n            stdio: ['ignore', outLog, errLog]\n        }).process;\n        p.unref();\n        return p;\n    },\n\n    /**\n     * A simple decrypt helper. Cross-version of node.\n     * @param  {Any} data\n     * @param  {String | Buffer} password\n     * @param  {String} algorithm Default is 'aes128'.\n     * @return {Buffer}\n     */\n    decrypt(data, password, algorithm) {\n        if (algorithm == null) {\n            algorithm = 'aes128';\n        }\n        const crypto = kit.require('crypto', __dirname);\n        const decipher = crypto.createDecipher(algorithm, password);\n\n        if (!Buffer.isBuffer(data)) {\n            data = Buffer.from(data);\n        }\n        return Buffer.concat([decipher.update(data), decipher.final()]);\n    },\n\n    /**\n     * The warp drives.\n     * You must `kit.require 'drives'` before using it.\n     * For more information goto the `Drives` section.\n     * @type {Object}\n     */\n    drives: null,\n\n    /**\n     * A simple encrypt helper. Cross-version of node.\n     * @param  {Any} data\n     * @param  {String | Buffer} password\n     * @param  {String} algorithm Default is 'aes128'.\n     * @return {Buffer}\n     */\n    encrypt(data, password, algorithm) {\n        if (algorithm == null) {\n            algorithm = 'aes128';\n        }\n        const crypto = kit.require('crypto', __dirname);\n        const cipher = crypto.createCipher(algorithm, password);\n\n        if (!Buffer.isBuffer(data)) {\n            data = Buffer.from(data);\n        }\n        return Buffer.concat([cipher.update(data), cipher.final()]);\n    },\n\n    /**\n     * A error log shortcut for `kit.log(msg, 'error', opts)`\n     * @param  {Any} msg\n     * @param  {Object} opts\n     */\n    err(msg, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        return kit.log(msg, 'error', opts);\n    },\n\n    /**\n     * Shortcut for logging multiple error infos.\n     * @param  {Any} args...\n     * @example\n     * ```js\n     * kit.errs('test1', 'test2', 'test3');\n     * // => [2015-02-07 08:31:49] test1 test2 test3\n     * ```\n     */\n    errs(...args) {\n        let out = '';\n        const last = args.length - 1;\n        for (var i = 0; i < args.length; i++) {\n            const arg = args[i];\n            kit.log(arg, {\n                isShowTime: false,\n                log(str) {\n                    return out += str + (i === last ? '' : ' ');\n                }\n            });\n        }\n        return kit.log(out, 'error');\n    },\n\n    /**\n     * A better `child_process.exec`. Supports multi-line shell script.\n     * For supporting old version of node, it will create 3 temp files,\n     * the temp files will be removed after the execution.\n     * @param  {String} cmd   Shell commands.\n     * @param  {String} shell Shell name. Such as `bash`, `zsh`. Optinal.\n     * @return {Promise} Resolves when the process's stdio is drained.\n     * The resolve value is like:\n     * ```js\n     * {\n     *     code: 0,\n     *     signal: null,\n     *     stdout: 'hello world',\n     *     stderr: ''\n     * }\n     * ```\n     * @example\n     * ```js\n     * kit.exec(`\n     *     a='hello world'\n     *     echo $a\n     * `).then(({code, stdout}) => {\n     *     kit.log code   // output => 0\n     *     kit.log stdout // output => \"hello world\"\n     * });\n     *\n     * // Bash doesn't support \"**\" recusive match pattern.\n     * let p = kit.exec(`\n     *  echo **\\/*.css\n     * `, 'zsh');\n     *\n     * // Get the child process object.\n     * p.process.then((proc) =>\n     *  kit.log(proc.pid)\n     * );\n     * ```\n     */\n    exec(cmd, shell) {\n        const os = kit.require('os', __dirname);\n\n        if (shell == null) {\n            shell = process.env.SHELL ||\n                process.env.ComSpec ||\n                process.env.COMSPEC;\n        }\n\n        const randName = Date.now() + Math.random();\n\n        const paths = ['.in', '.out', '.err']\n            .map(type => kit.path.join(os.tmpdir(), `nokit-${randName}${type}`));\n\n        const [stdinPath, stdoutPath, stderrPath] = Array.from(paths);\n\n        let fileHandlers = [];\n\n        const clean = () =>\n            Promise.all(fileHandlers.map(f => kit.close(f)))\n            .then(() => Promise.all(paths.map(p => kit.remove(p))));\n\n        let proc = null;\n        const processPromise = kit.outputFile(stdinPath, cmd + '\\n')\n            .then(() =>\n                Promise.all([\n                    kit.fs.open(stdinPath, 'r'),\n                    kit.fs.open(stdoutPath, 'w'),\n                    kit.fs.open(stderrPath, 'w')\n                ]))\n            .then(function (stdio) {\n                fileHandlers = fileHandlers.concat(stdio);\n                const p = kit.spawn(shell, [], {\n                    stdio\n                });\n                ({\n                    process: proc\n                } = p);\n                return p;\n            });\n\n        const promise = processPromise.then(msg =>\n                kit.readFile(stdoutPath, 'utf8')\n                .then(stdout => _.extend(msg, {\n                    stdout\n                })))\n            .catch(msg =>\n                kit.readFile(stderrPath, 'utf8')\n                .then(function (stderr) {\n                    _.extend(msg, {\n                        stderr\n                    });\n                    return Promise.reject(msg);\n                })\n            );\n\n        promise.process = processPromise.then(() => proc);\n\n        promise.then(clean).catch(clean);\n\n        return promise;\n    },\n\n    /**\n     * Format the parsed comments array to a markdown string.\n     * @param  {Array}  comments\n     * @param  {Object} opts Defaults:\n     * ```js\n     * {\n     *     indent: 0,\n     *     name: ({ name }) => String,\n     *     tag: ({ tagName, name, type }) => String\n     * }\n     * ```\n     * @return {String}\n     */\n    formatComment(comments, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        _.defaults(opts, {\n            indent: 0,\n            name({\n                name\n            }) {\n                name = name.replace('self.', '');\n                return `- #### ${name}\\n\\n`;\n            },\n            tag({\n                tagName,\n                name,\n                type\n            }) {\n                const tname = name ? ` \\`${name}\\`` : '';\n                const ttype = type ? ` { _${type}_ }` : '';\n                return `- **<u>${tagName}</u>**:${tname}${ttype}`;\n            }\n        });\n\n        let all = '';\n        for (let cmt of Array.from(comments)) {\n            if (_.some(cmt.tags, {\n                    tagName: 'private'\n                })) {\n                continue;\n            }\n\n            const paramList = _(cmt.tags)\n                .filter(tag => tag.tagName === 'param').map('name')\n                .value();\n\n            if (paramList.length > 0) {\n                cmt.name += `(${paramList.join(', ')})`;\n            } else if (_.find(cmt.tags, {\n                    tagName: 'return'\n                })) {\n                cmt.name += \"()\";\n            }\n\n            let cmtStr = opts.name(cmt);\n\n            if (cmt.description) {\n                cmtStr += kit.indent(cmt.description, 4);\n                cmtStr += '\\n\\n';\n            }\n\n            for (let tag of Array.from(cmt.tags)) {\n                cmtStr += kit.indent(opts.tag(tag), 4);\n                cmtStr += '\\n\\n';\n                if (tag.description) {\n                    cmtStr += kit.indent(tag.description, 8);\n                    cmtStr += '\\n\\n';\n                }\n            }\n\n            all += cmtStr;\n        }\n\n        // Remove tailing space\n        all = all.replace(/[ \\t]+$/mg, '');\n\n        return kit.indent(all, opts.indent);\n    },\n\n    /**\n     * See my project [nofs](https://github.com/ysmood/nofs).\n     *\n     * [Offline Documentation](?gotoDoc=nofs/readme.md)\n     */\n    fs,\n\n    /**\n     * Fuzzy search a string list by a key word.\n     * @param {String} keys The key word.\n     * @param {Array} list The list of string to search.\n     * @param {Object} opts Defaults:\n     * ```js\n     * {\n     *     result: (wrappedList) =>\n     *         wrappedList.minBy('distance').words,\n     *     threshold: (cOffset, keyLen, cIndex) =>\n     *         Infinity,\n     *     notFound: (cOffset, keyLen, cIndex) =>\n     *         Infinity,\n     *     span: (cOffset, keyLen, cIndex) =>\n     *         cOffset,\n     *     found: (cOffset, keyLen, cIndex) =>\n     *         (Math.exp(cOffset + 1) - 1) * (keyLen - cIndex),\n     *     tail: (cOffset, keyLen, cIndex, tailLen) =>\n     *         tailLen\n     * }\n     * ```\n     * @return {String} The best matched one. If not found,\n     * return undefined.\n     * @example\n     * ```js\n     * kit.fuzzySearch('hw', ['test', 'hello world', 'hey world'])\n     * // output => 'hey world'\n     *\n     * // To get a sortable weighted list.\n     * kit.fuzzySearch('hw', ['test', 'hello world', 'hey world'], {\n     *  result: (wrappedList) => wrappedList.value()\n     * });\n     * // output => [\n     * //  { distance: Infinity }\n     * //  { words: 'hello world', distance: 1110.069 }\n     * //  { words: 'hey world', distance: 159.849 }\n     * // ]\n     * ```\n     */\n    fuzzySearch(key, list, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        _.defaults(opts, {\n            result(list) {\n                return list.minBy('distance').words;\n            },\n            threshold() {\n                return Infinity;\n            },\n            notFound() {\n                return Infinity;\n            },\n            span(cOffset) {\n                return cOffset;\n            },\n            found(cOffset, keyLen, cIndex) {\n                return (Math.exp(cOffset + 1) - 1) * (keyLen - cIndex);\n            },\n            tail(cOffset, keyLen, cIndex, tailLen) {\n                return tailLen;\n            }\n        });\n\n        const wrappedList = _(list)\n            .map(function (words) {\n                let cIndex, cOffset;\n                let distance = 0;\n                const keyLen = key.length;\n                for (cIndex = 0; cIndex < key.length; cIndex++) {\n                    const c = key[cIndex];\n                    cOffset = words.indexOf(c, cOffset + 1);\n                    distance = cOffset < 0 ?\n                        opts.notFound(cOffset, keyLen, cIndex) :\n                        distance + opts.found(cOffset, keyLen, cIndex);\n\n                    distance += opts.span(cOffset, keyLen, cIndex);\n\n                    if (distance >= opts.threshold(cOffset, keyLen, cIndex)) {\n                        return {\n                            distance: Infinity\n                        };\n                    }\n                }\n\n                distance += opts.tail(cOffset, keyLen,\n                    cIndex, words.slice(cOffset).length);\n\n                if (distance >= opts.threshold(cOffset, keyLen, cIndex)) {\n                    return {\n                        distance: Infinity\n                    };\n                }\n\n                return {\n                    words,\n                    distance\n                };\n            });\n\n        return opts.result(wrappedList);\n    },\n\n    /**\n     * Generate a list of module paths from a name and a directory.\n     * @param  {String} moduleName The module name.\n     * @param  {String} dir        The root path. Default is current working dir.\n     * @param  {String} modDir     Default is 'node_modules'.\n     * @return {Array} Paths\n     * @example\n     * ```js\n     * // Suppose current working directory is '/home/a'\n     * kit.genModulePaths('test')\n     * // output => ['/home/a/node_modules/test', '/home/node_modules/test', '/node_modules/test']\n     * ```\n     */\n    genModulePaths(moduleName, dir, modDir) {\n        if (dir == null) {\n            dir = process.cwd();\n        }\n        if (modDir == null) {\n            modDir = 'node_modules';\n        }\n        const names = [];\n        while (true) { // eslint-disable-line\n            names.push(kit.path.join(dir, modDir, moduleName));\n            const pDir = kit.path.dirname(dir);\n\n            if (dir === pDir) {\n                break;\n            }\n            dir = pDir;\n        }\n        names.push(moduleName);\n        return names;\n    },\n\n    /**\n     * Indent a text block.\n     * @param {String} text\n     * @param {Int} num\n     * @param {String} char\n     * @param {RegExp} reg Default is `/^/mg`.\n     * @return {String} The indented text block.\n     * @example\n     * ```js\n     * // Increase\n     * kit.indent(\"one\\ntwo\", 2)\n     * // => \"  one\\n  two\"\n     *\n     * // Decrease\n     * kit.indent(\"--one\\n--two\", 0, '', /^--/mg)\n     * // => \"one\\ntwo\"\n     * ```\n     */\n    indent(text, num, char, reg) {\n        if (num == null) {\n            num = 0;\n        }\n        if (char == null) {\n            char = ' ';\n        }\n        if (reg == null) {\n            reg = /^/mg;\n        }\n        const prefix = _.repeat(char, num);\n        return text.replace(reg, prefix);\n    },\n\n    /**\n     * Nokit use it to check the running mode of the app.\n     * Overwrite it if you want to control the check logic.\n     * By default it returns the `rocess.env.NODE_ENV == 'development'`.\n     * @return {Boolean}\n     */\n    isDevelopment() {\n        return process.env.NODE_ENV === 'development';\n    },\n\n    /**\n     * Nokit use it to check the running mode of the app.\n     * Overwrite it if you want to control the check logic.\n     * By default it returns the `rocess.env.NODE_ENV == 'production'`.\n     * @return {Boolean}\n     */\n    isProduction() {\n        return process.env.NODE_ENV === 'production';\n    },\n\n    /**\n     * A fast helper to hash string or binary file.\n     * See my [jhash](https://github.com/ysmood/jhash) project.\n     * You must `kit.require 'jhash'` before using it.\n     *\n     * [Offline Documentation](?gotoDoc=jhash/readme.md)\n     * @example\n     * ```js\n     * kit.require('jhash');\n     * kit.jhash.hash('test'); // output => '349o'\n     *\n     * jhash.hash(kit.readFileSync('a.jpg'));\n     *\n     * // Control the hash char set.\n     * kit.jhash.setSymbols('abcdef');\n     * kit.jhash.hash('test'); // output => 'decfddfe'\n     *\n     * // Control the max length of the result hash value. Unit is bit.\n     * jhash.setMaskLen(10);\n     * jhash.hash('test'); // output => 'ede'\n     * ```\n     */\n    jhash: null,\n\n    /**\n     * A better log for debugging, it uses the `kit.xinspect` to log.\n     *\n     * Use terminal command like `logReg='pattern' node app.js` to\n     * filter the log info.\n     *\n     * Use `logTrace='on' node app.js` to force each log end with a\n     * stack trace.\n     * @param  {Any} msg Your log message.\n     * @param  {String} action 'log', 'error', 'warn'.\n     * @param  {Object} opts Default is same with `kit.xinspect`,\n     * but with some extra options:\n     * ```js\n     * {\n     *  isShowTime: true,\n     *  logReg: process.env.logReg && new RegExp(process.env.logReg),\n     *  logTrace: process.env.logTrace === 'on',\n     *\n     *  // Custom log method\n     *  log: (str, action) => console[action](str)\n     * }\n     * ```\n     * @example\n     * ```js\n     * kit.log('test');\n     * // => '[2015-02-07 08:31:49] test'\n     *\n     * kit.log('test', { isShowTime: false });\n     * // => 'test'\n     *\n     * kit.log('test', { logReg: /a/ });\n     * // => ''\n     *\n     * kit.log('%s %s %d', ['a', 'b', 10]);\n     * // => '[2015-02-07 08:31:49] a b 10'\n     * ```\n     */\n    log(...args) {\n        let action, formats, opts, time, timeDelta;\n        const br = kit.require('brush');\n\n        if (_.isObject(action)) {\n            opts = action;\n            action = 'log';\n        }\n\n        let msg = args[0];\n        ({\n            action,\n            formats,\n            opts\n        } = kit.defaultArgs(args.slice(1), {\n            action: {\n                String: 'log'\n            },\n            formats: {\n                Array: null\n            },\n            opts: {\n                Object: {}\n            }\n        }));\n\n        _.defaults(opts, {\n            isShowTime: true,\n            logReg: process.env.logReg && new RegExp(process.env.logReg),\n            logTrace: process.env.logTrace === 'on',\n            log: null\n        });\n\n        if (!kit.lastLogTime) {\n            kit.lastLogTime = new Date;\n            if (opts.logReg) {\n                kit.logReg = opts.logReg;\n            }\n        }\n\n        if (opts.isShowTime) {\n            time = new Date();\n            timeDelta = br.grey((+time - +kit.lastLogTime) + 'ms');\n            kit.lastLogTime = time;\n            time = br.grey([\n                [\n                    [time.getFullYear(), 4, '0'],\n                    [time.getMonth() + 1, 2, '0'],\n                    [time.getDate(), 2, '0']\n                ].map(e => _.padStart.apply(0, e)).join('-'), [\n                    [time.getHours(), 2, '0'],\n                    [time.getMinutes(), 2, '0'],\n                    [time.getSeconds(), 2, '0']\n                ].map(e => _.padStart.apply(0, e)).join(':')\n            ].join(' '));\n        }\n\n        const log = function (str, time) {\n            if (opts.isShowTime) {\n                str = str + ' ' + time;\n            }\n\n            if (kit.logReg && !kit.logReg.test(str)) {\n                return;\n            }\n\n            if (opts.log) {\n                opts.log(str, action);\n            } else {\n                console[action](str);\n            }\n\n            if (opts.logTrace) {\n                const err = br.grey((new Error).stack)\n                    .replace(/.+\\n.+\\n.+/, '\\nStack trace:');\n                return console.log(err);\n            }\n        };\n\n        if (_.isObject(msg)) {\n            if (opts.isShowTime) {\n                log(`[${time}] ->\\n` + kit.xinspect(msg, opts), timeDelta);\n            } else {\n                log(kit.xinspect(msg, opts));\n            }\n        } else {\n            if (formats) {\n                formats.unshift(msg);\n                const util = kit.require('util', __dirname);\n                msg = util.format.apply(0, formats);\n            }\n\n            if (opts.isShowTime) {\n                log(`[${time}] ` + msg, timeDelta);\n            } else {\n                log(msg, timeDelta);\n            }\n        }\n\n        if (action === 'error') {\n            process.stderr.write(\"\\u0007\");\n        }\n\n    },\n\n    /**\n     * Shortcut for logging multiple infos.\n     * @param  {Any} args...\n     * @example\n     * ```js\n     * kit.logs('test1', 'test2', 'test3');\n     * // => [2015-02-07 08:31:49] test1 test2 test3\n     * ```\n     */\n    logs(...args) {\n        let out = '';\n        const last = args.length - 1;\n        for (var i = 0; i < args.length; i++) {\n            const arg = args[i];\n            kit.log(arg, {\n                isShowTime: false,\n                log(str) {\n                    return out += str + (i === last ? '' : ' ');\n                }\n            });\n        }\n        return kit.log(out);\n    },\n\n    /**\n     * Monitor an application and automatically restart it when file changed.\n     * Even when the monitored app exit with error, the monitor will still wait\n     * for your file change to restart the application. Not only nodejs, but also\n     * other programs like ruby or python.\n     * It will print useful infomation when it application unexceptedly.\n     * @param  {Object} opts Defaults:\n     * ```js\n     * {\n     *  bin: 'node',\n     *  args: ['index.js'],\n     *  prefix: 'string', // see the `kit.spawn` for details\n     *  watchList: [], // By default, the same with the \"args\".\n     *  isNodeDeps: true,\n     *  opts: {}, // Same as the opts of 'kit.spawn'.\n     *\n     *  // The option of `kit.parseDependency`\n     *  parseDependency: {},\n     *\n     *  // A hook for restarting the program, run the function \"start\" to\n     *  // restart.\n     *  retry: (start) => {},\n     *\n     *  onStart: =>\n     *      kit.log(\"Monitor: \" + opts.watchList),\n     *  onRestart: (path) =>\n     *      kit.log(\"Reload app, modified: \" + path),\n     *  onWatchFiles: (paths) =>\n     *      kit.log('Watching:' + paths.join(', ')),\n     *  onNormalExit: ({ code, signal }) =>\n     *      kit.log('EXIT' +\n     *          ` code: ${code} signal: ${signal}`),\n     *  onErrorExit: ({ code, signal }) =>\n     *      kit.err('EXIT' +\n     *      ` code: ${code} signal: ${signal}\\n` +\n     *      'Process closed. Edit and save the watched file to restart.'),\n     * }\n     * ```\n     * @return {Object} Properties:\n     * ```js\n     * {\n     *  // Call it to stop monitor.\n     *  stop: => {},\n     *\n     *  // Resolve a list of watch handlers.\n     *  watchPromise: Promise\n     * }\n     * ```\n     * @example\n     * ```js\n     * kit.monitorApp({\n     *  bin: 'coffee',\n     *  args: ['main.coffee']\n     * });\n     *\n     * kit.monitorApp({\n     *  bin: 'ruby'\n     *  args: ['app.rb', 'lib\\/**\\/*.rb']\n     *  isNodeDeps: false\n     * });\n     * ```\n     */\n    monitorApp(opts) {\n        const br = kit.require('brush');\n        const treeKill = kit.require('treeKill');\n\n        _.defaults(opts, {\n            bin: 'node',\n            args: ['index.js'],\n            retry() {},\n            watchList: null,\n            watchRoot: null,\n            isNodeDeps: true,\n            parseDependency: {},\n            opts: {},\n            onStart() {\n                return kit.logs(br.yellow(\"Monitor:\"), opts.bin, opts.watchList);\n            },\n            onRestart(path) {\n                return kit.log(br.yellow(\"Reload app, modified: \") + path);\n            },\n            onWatchFiles(paths) {\n                const cwd = process.cwd();\n                return kit.log(br.yellow('Watching: ') +\n                    paths.map(p => kit.path.relative(cwd, p)).join(', ')\n                );\n            },\n            onNormalExit({\n                code,\n                signal\n            }) {\n                kit.log(br.yellow('EXIT') +\n                    ` code: ${br.cyan(code)} signal: ${br.cyan(signal)}`\n                );\n                return console.log('\\n');\n            },\n            onErrorExit({\n                code,\n                signal\n            }) {\n                kit.err(br.yellow('EXIT') +\n                    ` code: ${br.cyan(code)} ` +\n                    `signal: ${br.cyan(signal)}\\n` +\n                    br.red(`Process closed. Edit and save the watched file to restart.`)\n                );\n                return console.log('\\n');\n            }\n        });\n\n        if (opts.watchList == null) {\n            opts.watchList = opts.args;\n        }\n\n        let childPromise = null;\n        var start = function () {\n            childPromise = kit.spawn(\n                opts.bin,\n                opts.args,\n                opts.opts\n            );\n\n            return childPromise.then(msg => opts.onNormalExit(msg)).catch(function (err) {\n                if (err.stack) {\n                    return Promise.reject(err.stack);\n                }\n                return opts.onErrorExit(err);\n            }).then(() => opts.retry(start));\n        };\n\n        let watchedList = [];\n\n        const watcher = _.debounce(function (path) {\n            opts.onRestart(path);\n\n            childPromise.catch(function () {}).then(start);\n            return treeKill(childPromise.process.pid, 'SIGINT', _.noop);\n        }, 50);\n\n        const stop = function (sig) {\n            if (sig == null) {\n                sig = 'SIGINT';\n            }\n            treeKill(childPromise.process.pid, sig, _.noop);\n\n            return watchPromise.then(() => Array.from(watchedList).map((w) => kit.unwatchFile(w.path, w.handler)));\n        };\n\n        const watch = function (paths) {\n            if (_.isString(paths)) {\n                paths = [paths];\n            }\n            paths = _.difference(\n                (paths.map(p => kit.path.resolve(p))),\n                (watchedList.map(w => kit.path.resolve(w.path)))\n            );\n            if (paths.length > 0) {\n                opts.onWatchFiles(paths);\n            }\n            return kit.watchFiles(paths, {\n                    handler: watcher\n                })\n                .then(ws => watchedList = watchedList.concat(ws));\n        };\n\n        process.on('SIGINT', function () {\n            // it will unconditionally terminate Node.js on all platforms\n            stop('SIGKILL');\n            return process.exit();\n        });\n\n        var watchPromise = opts.watchRoot ?\n            kit.watchDir(opts.watchRoot, {\n                patterns: opts.watchList,\n                handler(type, path) {\n                    return watcher(path);\n                }\n            }) :\n            opts.isNodeDeps ?\n            kit.parseDependency(opts.watchList, opts.parseDependency)\n            .then(watch) :\n            kit.watchFiles(opts.watchList, {\n                handler: watcher\n            });\n\n        opts.onStart();\n\n        start();\n\n        return {\n            watchPromise,\n            stop,\n            watch\n        };\n    },\n\n    /**\n     * Node version. Such as `v0.10.23` is `0.1023`, `v0.10.1` is `0.1001`.\n     * @return {Float}\n     */\n    nodeVersion() {\n        if (kit.nodeVersion.ver) {\n            return kit.nodeVersion.ver;\n        }\n        const ms = process.versions.node.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n        const str = ms[1] + '.' + _.padStart(ms[2], 2, '0') + _.padStart(ms[3], 2, '0');\n        return kit.nodeVersion.ver = +str;\n    },\n\n    /**\n     * A helper for arguments type based function override.\n     * @param  {Array | Object} args The arguments to set.\n     * @param  {Object} defaults The default argument settings.\n     * The key value of the setting is the argument name, the value\n     * is an object, and the key is the type of the argument, the\n     * value is the default value of the argument.\n     * @return {Object}\n     * @example\n     * ```js\n     * let foo = () => {\n     *     kit.defaultArgs(arguments, {\n     *         name: { String: 'A' },\n     *         brush: { Array: [] },\n     *         family: { String: null },\n     *         isReal: { Boolean: false },\n     *         fn: { Function: => 'callback' }\n     *     });\n     * };\n     *\n     * kit.log(foo('test', false, ['red'], -> 'nothing'));\n     * // Here the logged value will deeply equal:\n     * { name: 'test', brush: ['red'], family: null, fn: => 'nothing' }\n     * ```\n     */\n    defaultArgs(args, defaults) {\n        const set = _(args).toArray().groupBy(function (e) {\n            if (e) {\n                if (e.constructor.name === 'AsyncFunction') {\n                    return 'Function';\n                } else {\n                    return e.constructor.name;\n                }\n            }\n        }).value();\n\n        const ret = {};\n        for (let name in defaults) {\n            var val = defaults[name];\n            var [type] = Array.from(_.keys(val));\n            ret[name] = (() => {\n                if (set[type]) {\n                    const [v] = Array.from(set[type].splice(0, 1));\n                    if (v) {\n                        return v;\n                    } else {\n                        return val[type];\n                    }\n                } else {\n                    return val[type];\n                }\n            })();\n        }\n        return ret;\n    },\n\n    /**\n     * A comments parser for javascript and coffee-script.\n     * Used to generate documentation from source code automatically.\n     * It will traverse through all the comments of a coffee file.\n     * @param  {String} code Coffee source code.\n     * @param  {Object} opts Parser options:\n     * ```js\n     * {\n     *     commentReg: RegExp,\n     *     splitReg: RegExp,\n     *     tagNameReg: RegExp,\n     *     typeReg: RegExp,\n     *     nameReg: RegExp,\n     *     nameTags: ['param', 'property'],\n     *     descriptionReg: RegExp\n     * }\n     * ```\n     * @return {Array} The parsed comments. Each item is something like:\n     * ```js\n     * {\n     *     name: 'parseComment',\n     *     description: 'A comments parser for coffee-script.',\n     *     tags: [\n     *         {\n     *             tagName: 'param',\n     *             type: 'string',\n     *             name: 'code',\n     *             description: 'The name of the module it belongs to.',\n     *             index: 256, // The target char index in the file.\n     *             line: 32 // The line number of the target in the file.\n     *         }\n     *     ]\n     * }\n     * ```\n     */\n    parseComment(code, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        _.defaults(opts, {\n            commentReg: new RegExp(`(?:\\\\#\\\\#\\\\#|\\\\/\\\\*)\\\\*([\\\\s\\\\S]+?)(?:\\\\#\\\\#\\\\#|\\\\*\\\\/)\\\\s+(?:var\\\\s|let\\\\s|const\\\\s|function\\\\s+)?['\"]?([$@\\\\w\\\\.-]+)['\"]?`, 'g'),\n            splitReg: /^\\s+\\* @/m,\n            tagNameReg: /^([\\w.]+)\\s*/,\n            typeReg: /^\\{(.+?)\\}\\s*/,\n            nameReg: /^(\\[.+\\]|\\w+)\\s*/,\n            nameTags: ['param', 'property'],\n            descriptionReg: /^([\\s\\S]*)/\n        });\n\n        const parseInfo = function (block) {\n            // Unescape '\\/'\n            block = block.replace(/\\\\\\//g, '/');\n\n            // Clean the prefix '*'\n            const arr = block.split(opts.splitReg).map(el => el.replace(/^[ \\t]+\\*[ \\t]?/mg, '').trim());\n\n            return {\n                description: arr[0] || '',\n                tags: arr.slice(1).map(function (el) {\n                    const parseTag = function (reg) {\n                        const m = el.match(reg);\n                        if (m && m[1]) {\n                            el = el.slice(m[0].length);\n                            return m[1];\n                        } else {\n                            return null;\n                        }\n                    };\n\n                    const tag = {};\n\n                    tag.tagName = parseTag(opts.tagNameReg);\n\n                    const type = parseTag(opts.typeReg);\n                    if (type) {\n                        tag.type = type;\n                        if (Array.from(opts.nameTags).includes(tag.tagName)) {\n                            tag.name = parseTag(opts.nameReg);\n                        }\n                        tag.description = parseTag(opts.descriptionReg) || '';\n                    } else {\n                        tag.description = parseTag(opts.descriptionReg) || '';\n                    }\n                    return tag;\n                })\n            };\n        };\n\n        const comments = [];\n        let m = null;\n        while ((m = opts.commentReg.exec(code)) !== null) {\n            const info = parseInfo(m[1]);\n            comments.push({\n                name: m[2],\n                description: info.description,\n                tags: info.tags,\n                index: opts.commentReg.lastIndex,\n                line: _.reduce(code.slice(0, opts.commentReg.lastIndex), function (count, char) {\n                    if (char === '\\n') {\n                        count++;\n                    }\n                    return count;\n                }, 1)\n            });\n        }\n\n        return comments;\n    },\n\n    /**\n     * Parse dependency tree by regex. The dependency relationships\n     * is not a tree, but a graph. To avoid dependency cycle, this\n     * function only return an linear array of the dependencies,\n     * from which you won't get the detail relationshops between files.\n     * @param  {String | Array} entryPaths The file to begin with.\n     * @param  {Object} opts Defaults:\n     * ```js\n     * {\n     *  // It will match `require`, `import` statements.\n     *  depReg: RegExp,\n     *\n     *  // It will handle all the matched paths.\n     *  // Return false value if you don't want this match.\n     *  handle: (path) => path\n     * }\n     * ```\n     * @return {Promise} It resolves the dependency path array.\n     * @example\n     * ```js\n     * kit.parseDependency('main.', {\n     *  depReg: /require\\s*\\(?['\"](.+)['\"]\\)?/gm,\n     *  handle: (path) => {\n     *      if (path.match(/^(?:\\.|\\/|[a-z]:)/i)) return path;\n     *  }\n     * })\n     * .then((markdownStr) =>\n     *  kit.log(markdownStr)\n     * );\n     * ```\n     */\n    parseDependency(entryPaths, opts, depPaths) {\n        if (opts == null) {\n            opts = {};\n        }\n        if (depPaths == null) {\n            depPaths = {};\n        }\n        _.defaults(opts, {\n            depReg: kit.parseDependencyReg,\n            handle: _.identity,\n            visitedPaths: {}\n        });\n\n        const winSep = /\\\\/g;\n\n        if (_.isString(entryPaths)) {\n            entryPaths = [entryPaths];\n        }\n\n        entryPaths = entryPaths.reduce(function (s, p) {\n            if (opts.visitedPaths[p]) {\n                return s;\n            } else {\n                opts.visitedPaths[p] = true;\n            }\n\n            if (kit.path.extname(p)) {\n                s.push(p);\n            } else {\n                s.push(p + '{/index.,}*');\n            }\n\n            return s;\n        }, []);\n\n        // Parse file.\n        return kit.glob(entryPaths).then(paths =>\n            Promise.all(paths.map(function (path) {\n                // Prevent the recycle dependencies.\n                if (depPaths[path]) {\n                    return;\n                }\n\n                return kit.readFile(path, 'utf8')\n                    .then(function (str) {\n                        // The point to add path to watch list.\n                        depPaths[path.replace(winSep, '/')] = true;\n                        const dir = kit.path.dirname(path);\n\n                        entryPaths = [];\n                        str.replace(opts.depReg, function (n0, ...rest) {\n                            const adjustedLength = Math.max(rest.length, 2),\n                                ms = rest.slice(0, adjustedLength - 2);\n                            const p = opts.handle(_.find(ms, _.isString));\n                            if (!p) {\n                                return;\n                            }\n                            return entryPaths.push(kit.path.join(dir, p));\n                        });\n\n                        return kit.parseDependency(entryPaths, opts, depPaths);\n                    }).catch(_.noop);\n            }))).then(() => _.keys(depPaths));\n    },\n\n    parseDependencyReg: new RegExp(`require\\\\s*\\\\(?['\"](.+)['\"]\\\\)?|^\\\\s*import\\\\s+['\"](.+)['\"][;\\\\s]*$|^\\\\s*import[\\\\s\\\\S]+?from\\\\s+['\"](.+)['\"]`, 'mg'),\n\n    /**\n     * io.js native module `path`. See `nofs` for more information.\n     */\n    path: fs.path,\n\n    /**\n     * The promise lib. Now, it uses Yaku as ES5 polyfill.\n     * In the future, the Yaku will be replaced with native\n     * ES6 Promise. Please don't use any API other than the ES6 spec.\n     * @type {Object}\n     */\n    Promise,\n\n    /**\n     * The `proxy` module.\n     * You must `kit.require 'proxy'` before using it.\n     * For more information goto the `Proxy` section.\n     */\n    proxy: null,\n\n    /**\n     * Reduce a string via a regex.\n     * @param  {RegExp} reg\n     * @param  {String} str\n     * @param  {Function} iter `(init, matchGroup) -> init`, default is `_.iteratee`.\n     * @param  {Any} init\n     * @return {Any}\n     * @example\n     * ```js\n     * let out = kit.regexReduce(/\\w(\\d+)/g, 'a1, b10, c3', (ret, ms) => {\n     *  ret.push(ms[1]);\n     *  return ret;\n     * }, []);\n     *\n     * kit.log(out); // => [1, 10, 3]\n     * ```\n     */\n    regexReduce(reg, str, iter, init) {\n        iter = _.iteratee(iter);\n        let ms = null;\n        if (reg.global) {\n            while ((ms = reg.exec(str)) !== null) {\n                init = iter(init, ms);\n            }\n        } else {\n            return iter(init, reg.exec(str));\n        }\n\n        return init;\n    },\n\n    /**\n     * Map a string via a regex.\n     * @param  {RegExp} reg\n     * @param  {String} str\n     * @param  {Function} iter `(matchGroup) ->`, default is `_.iteratee`.\n     * @return {Array}\n     * @example\n     * ```js\n     * let out = kit.regexMap(/\\w(\\d+)/g, 'a1, b10, c3', 1);\n     *\n     * kit.log(out) // => [1, 10, 3]\n     * ```\n     */\n    regexMap(reg, str, iter) {\n        iter = _.iteratee(iter);\n        let ms = null;\n        const init = [];\n        if (reg.global) {\n            while ((ms = reg.exec(str)) !== null) {\n                init.push(iter(ms));\n            }\n        } else {\n            return iter.push(reg.exec(str));\n        }\n\n        return init;\n    },\n\n    /**\n     * An async string replace function.\n     * @param  {String} str     The string to replace\n     * @param  {String | Regex} pattern\n     * @param  {Function} iter It can return a promise\n     * @return {Promise}\n     */\n    replace(str, pattern, iter) {\n        const promises = [];\n\n        if (iter == null) {\n            iter = (p, m) => m;\n        }\n\n        str.replace(pattern, function () {\n            const offset = arguments[arguments.length - 2];\n            const start = offset + arguments[0].length;\n\n            promises.push(\n                Promise.resolve(iter.apply(null, arguments))\n                .then(res => [offset, start, res])\n            );\n\n        });\n\n        return Promise.all(promises).then(function (list) {\n            let out = '';\n            let start = 0;\n            let end = 0;\n\n            for (let item of Array.from(list)) {\n                end = item[0];\n                out += str.slice(start, end) + item[2];\n                start = item[1];\n            }\n\n            out += str.slice(start);\n            return out;\n        });\n    },\n\n    /**\n     * An async string replace function, each replacement process will run in line.\n     * @param  {String} str     The string to replace\n     * @param  {String | Regex} pattern\n     * @param  {Function} iter It can return a promise\n     * @return {Promise}\n     */\n    replaceSync(str, pattern, iter) {\n        let out = '';\n        let promise = Promise.resolve();\n        let start = 0;\n        let end = 0;\n\n        if (iter == null) {\n            iter = (p, m) => m;\n        }\n\n        str.replace(pattern, function () {\n            const arr = _.toArray(arguments);\n            const offset = arr[arr.length - 2];\n\n            promise = promise.then(() => iter.apply(null, arr)).then(function (res) {\n                end = offset;\n                out += str.slice(start, end) + res;\n                start = offset + arr[0].length;\n            });\n\n        });\n\n        return promise.then(function () {\n            out += str.slice(start);\n            return out;\n        });\n    },\n\n    /**\n     * Much faster than the native require of node, but you should\n     * follow some rules to use it safely.\n     * Use it to load nokit's internal module.\n     * @param {String} moduleName The module path or name.\n     * @param {String} dir Current absolute file path. Not optional, expect when\n     * requiring nokit's internal modules.\n     * On most times, just pass `__dirname` to it is enough.\n     * @param {Function} loaded Run only the first time after the module loaded.\n     * @return {Module} The module that you require.\n     * @example\n     * Use it to load nokit's internal module.\n     * ```js\n     * kit.require('jhash');\n     * // Then you can use the module, or it will be null.\n     * kit.jhash.hash('test');\n     * ```\n     * To load a relative path, or you own module,\n     * the second parameter 'dir' is required.\n     * ```js\n     * let mod = kit.require('./mod', __dirname);\n     *\n     * // Or load your own 'jhash', rather than nokit's.\n     * let jhash = kit.require('jhash', __dirname);\n     * ```\n     */\n    require(moduleName, dir, loaded) {\n        let e, modPath;\n        if (_.isFunction(dir)) {\n            loaded = dir;\n            dir = null;\n        }\n\n        const key = moduleName + (dir ? `@${dir}` : '');\n\n        if (kit.requireCache[key]) {\n            return kit.requireCache[key];\n        }\n\n        if ((dir == null)) {\n            if ((moduleName[0] === '.') || (kit[moduleName] !== null)) {\n                const err = new Error(\n                    \"[kit.require] argument 'dir' is not defined: \" +\n                    moduleName\n                );\n                err.source = 'nokit';\n                throw err;\n            }\n\n            try {\n                modPath = require.resolve(`./${moduleName}`);\n            } catch (error) {\n                e = error;\n                if (e.code !== 'MODULE_NOT_FOUND') {\n                    throw e;\n                }\n            }\n\n            if (modPath) {\n                return kit[moduleName] =\n                    (kit.requireCache[key] =\n                        require(modPath));\n            }\n\n            return kit[moduleName] =\n                (kit.requireCache[key] =\n                    require(moduleName));\n        }\n\n        const names = moduleName[0] === '.' ? [kit.path.join(dir, moduleName)] :\n            kit.genModulePaths(moduleName, dir)\n            .concat(process.env.NODE_PATH ?\n                Array.from(process.env.NODE_PATH.split(kit.path.delimiter)).map((p) =>\n                    kit.path.join(p, moduleName)) :\n                []);\n\n\n        for (let name of Array.from(names)) {\n            try {\n                modPath = require.resolve(name);\n            } catch (error1) {\n                e = error1;\n                if (e.code === 'MODULE_NOT_FOUND') {\n                    modPath = null;\n                } else {\n                    throw e;\n                }\n            }\n\n            if (modPath) {\n                kit.requireCache[key] = require(modPath);\n                if (typeof loaded === 'function') {\n                    loaded(kit.requireCache[key]);\n                }\n                break;\n            }\n        }\n\n        if (!kit.requireCache[key]) {\n            e = new Error(`Module not found: ${moduleName}`);\n            e.code = 'MODULE_NOT_FOUND';\n            throw e;\n        }\n\n        if (kit[moduleName] === null) {\n            kit[moduleName] = kit.requireCache[key];\n        }\n\n        return kit.requireCache[key];\n    },\n\n    /**\n     * Require an optional package. If not found, it will\n     * warn the user to npm install it, and exit the process.\n     * When `kit.requireOptional.autoInstall` is set to `true`, the package will\n     * be auto installed if it's missed.\n     * @param {String} name Package name\n     * @param {String} dir Current absolute file path. Not optional.\n     * On most times, just pass `__dirname` to it is enough.\n     * @param  {String} semver Specify what version you need,\n     * such as `^0.3.1` or `>=1.2.3`, ect.\n     * @return {Any} The required package.\n     */\n    requireOptional(name, dir, semver) {\n        const key = semver ? name + '@' + semver : name;\n        if (kit.requireCache[key]) {\n            return kit.requireCache[key];\n        }\n\n        try {\n            if (semver) {\n                kit.require('semver');\n                const {\n                    version\n                } = kit.require(name + '/package.json', dir);\n                if (!kit.semver.satisfies(version, semver)) {\n                    const info = `expect ${name} version ` +\n                        `'${semver}', but get '${version}'`;\n                    name = `${name}@\"${semver}\"`;\n                    throw new Error(info);\n                }\n            }\n\n            return kit.require(name, dir);\n        } catch (err) {\n            const br = kit.require('brush');\n\n            if (kit.requireOptional.autoInstall) {\n                const {\n                    spawnSync\n                } = kit.require('child_process', __dirname);\n                const whichSync = kit.require('whichSync');\n                spawnSync(whichSync('npm'), ['i', key], {\n                    cwd: dir,\n                    stdio: 'inherit'\n                });\n                try {\n                    return kit.require(name, dir);\n                } catch (err) {\n                    if (err && err.code === 'MODULE_NOT_FOUND') {\n                        kit.errs(br.red('Optional module installed, please rerun the program.'), err.stack)\n                        process.exit(1)\n                    } else {\n                        throw err\n                    }\n                }\n            }\n\n            if (err.source === 'nokit') {\n                throw err;\n            }\n\n            kit.err(\n                (br.red(\"Optional module required. Please \" +\n                    br.green(`'npm install -S ${name}'` + br.red(\" first.\\n\")))) +\n                err.stack, {\n                    isShowTime: false\n                });\n            return process.exit(1);\n        }\n    },\n\n    /**\n     * A handy extended combination of `http.request` and `https.request`.\n     * @param  {Object} opts The same as the [http.request](http://nodejs.org/api/http.html#httpHttpRequestOptionsCallback),\n     * but with some extra options:\n     * ```js\n     * {\n     *  // String or Url Object.\n     *  url: String | Object,\n     *\n     *  // Other than return `res` with `res.body`,return `body` directly.\n     *  body: true,\n     *\n     *  // Max times of auto redirect. If 0, no auto redirect.\n     *  redirect: 0,\n     *\n     *  // Timeout of the socket of the http connection.\n     *  // If timeout happens, the promise will reject.\n     *  // Zero means no timeout.\n     *  timeout: 0,\n     *\n     *  // The key of headers should be lowercased.\n     *  headers: {},\n     *\n     *  protocol: 'http:' or 'https:',\n     *\n     *  agent: null,\n     *\n     *  // Auto set \"transfer-encoding\" header to 'chunked' if the `reqData` is\n     *  // stream and the 'Content-Length' header is not set.\n     *  autoTE: true,\n     *\n     *  // Set null to use buffer, optional.\n     *  // It supports GBK, ShiftJIS etc.\n     *  // For more info, see https://github.com/ashtuchkin/iconv-lite\n     *  resEncoding: 'auto',\n     *\n     *  // Whether to unzip gzip / deflate.\n     *  autoUnzip: true,\n     *\n     *  // It's string, object, stream or buffer, it's optional. When it's an object,\n     *  // The request will be 'application/x-www-form-urlencoded'.\n     *  reqData: null,\n     *\n     *  // auto end the request.\n     *  autoEndReq: true,\n     *\n     *  // Writable stream.\n     *  resPipe: null,\n     *\n     *  // Handle resPipe before it's piped.\n     *  // Its returned value will be assigned to `opts.resPipe`. So you can return\n     *  // null to make the request resolve the `body`.\n     *  handleResPipe: (res, resPipe) => resPipe,\n     *\n     *  /// The progress of the request.\n     *  reqProgress: (complete, total) => {},\n     *\n     *  // The progress of the response.\n     *  resProgress: (complete, total) => {},\n     *\n     *  resPipeError: (res) => res.end()\n     * }\n     * ```\n     * And if set opts as string, it will be treated as the url.\n     * @return {Promise} Contains the http response object,\n     * it has an extra `body` property.\n     * You can also get the request object by using `Promise.req`.\n     * @example\n     * ```js\n     * let p = kit.request('http://test.com');\n     * p.req.on('response', (res) =>\n     *  kit.log res.headers['content-length']\n     * );\n     * p.then((body) =>\n     *  kit.log(body); // html or buffer\n     * );\n     *\n     * kit.request({\n     *  url: {\n     *      protocol: 'https', hostname: 'test.com',\n     *      port: 8123, path: '/a.mp3?s=1'\n     *  },\n     *  body: false,\n     *  resProgress: (complete, total) =>\n     *      kit.log(`Progress: ${complete} / ${total}`)\n     * })\n     * .then((res) => {\n     *  kit.log(res.body.length);\n     *  kit.log(res.headers);\n     * });\n     *\n     * // Send form-data.\n     * let form = new require('form-data');\n     * form.append('image', Buffer.alloc(0), {\n     *  filename: 'a.jpg', contentType: 'image/jpg'\n     * });\n     * form.append('key', 'value');\n     * kit.request({\n     *  url: 'a.com',\n     *  method: 'POST',\n     *  headers: form.getHeaders(),\n     *\n     *  reqData: form\n     * })\n     * .then((body) =>\n     *  kit.log(body)\n     * );\n     * ```\n     */\n    request(opts) {\n        let reqBuf;\n        if (_.isString(opts)) {\n            opts = {\n                url: opts\n            };\n        }\n\n        let url = opts.url || {};\n        if (_.isObject(url)) {\n            let hostSepIndex;\n            if (url.protocol == null) {\n                url.protocol = 'http:';\n            }\n            if (url.host && ((hostSepIndex = url.host.indexOf(':')) > -1)) {\n                url.hostname = url.host.slice(0, hostSepIndex);\n                url.port = url.host.slice(hostSepIndex + 1);\n            }\n        } else {\n            if (url.indexOf('http') !== 0) {\n                url = `http://${url}`;\n            }\n            url = nodeUrl.parse(url);\n            if (url.protocol == null) {\n                url.protocol = 'http:';\n            }\n            delete url.host;\n        }\n\n        _.defaults(opts, url);\n\n        let request = null;\n        switch (opts.protocol) {\n            case 'http:':\n                ({\n                    request\n                } = kit.require('http', __dirname));\n                break;\n            case 'https:':\n                ({\n                    request\n                } = kit.require('https', __dirname));\n                break;\n            default:\n                Promise.reject(new Error(`Protocol not supported: ${opts.protocol}`));\n        }\n\n        _.defaults(opts, {\n            body: true,\n            resEncoding: 'auto',\n            reqData: null,\n            autoEndReq: true,\n            autoUnzip: true,\n            reqProgress: null,\n            resProgress: null,\n            autoTE: true\n        });\n\n        if (opts.headers == null) {\n            opts.headers = {};\n        }\n        if (Buffer.isBuffer(opts.reqData)) {\n            reqBuf = opts.reqData;\n        } else if (_.isString(opts.reqData)) {\n            reqBuf = Buffer.from(opts.reqData);\n        } else if (_.isObject(opts.reqData)) {\n            if (opts.reqData && _.isFunction(opts.reqData.pipe)) {\n                opts.reqPipe = opts.reqData;\n            } else {\n                if (opts.headers['content-type'] == null) {\n                    opts.headers['content-type'] =\n                        'application/x-www-form-urlencoded; charset=utf-8';\n                }\n                reqBuf = Buffer.from(\n                    _.map(opts.reqData, (v, k) => [encodeURIComponent(k), encodeURIComponent(v)].join('=')).join('&')\n                );\n            }\n        } else {\n            reqBuf = undefined;\n        }\n\n        if (reqBuf !== undefined) {\n            if (opts.headers['content-length'] == null) {\n                opts.headers['content-length'] = reqBuf.length;\n            }\n        }\n\n        if (opts.autoTE && (!('content-length' in opts.headers)) &&\n            (!('Content-Length' in opts.headers)) && opts.reqPipe) {\n            opts.headers['transfer-encoding'] = 'chunked';\n        }\n\n        let req = null;\n        const promise = new Promise(function (resolve, reject) {\n            let resPipeError;\n            req = request(opts, function (res) {\n                let unzip;\n                let resStream = res;\n\n                if ((opts.redirect > 0) && res.headers.location) {\n                    opts.redirect--;\n                    url = nodeUrl.resolve(\n                        nodeUrl.format(opts),\n                        res.headers.location\n                    );\n                    kit.request(_.extend(opts, nodeUrl.parse(url)))\n                        .then(resolve)\n                        .catch(reject);\n                    return;\n                }\n\n                if (opts.resProgress) {\n                    (function () {\n                        const total = +res.headers['content-length'];\n                        let complete = 0;\n                        return resStream.on('data', function (chunk) {\n                            complete += chunk.length;\n                            return opts.resProgress(complete, total);\n                        });\n                    })();\n                }\n\n                if (_.isFunction(opts.handleResPipe)) {\n                    opts.resPipe = opts.handleResPipe(res, opts.resPipe);\n                }\n\n                if (opts.autoUnzip) {\n                    unzip = (() => {\n                        switch (res.headers['content-encoding']) {\n                            case 'gzip':\n                                return unzip = kit.require('zlib', __dirname).createGunzip();\n                            case 'deflate':\n                                return unzip = kit.require('zlib', __dirname).createInflateRaw();\n                        }\n                    })();\n\n                    if (unzip) {\n                        let isEmptyZipPipe = true;\n                        resStream = res.pipe(unzip);\n                        unzip.on('data', () => isEmptyZipPipe = false);\n                        unzip.on('error', function (err) {\n                            // Empty pipe to gzip\n                            if (isEmptyZipPipe) {\n                                return resolver(buf);\n                            } else {\n                                return reject(err);\n                            }\n                        });\n                    }\n                }\n\n                if (resPipeError) {\n                    resStream.on('error', resPipeError);\n                }\n\n                if (opts.resPipe) {\n                    resStream.pipe(opts.resPipe);\n\n                    opts.resPipe.on('error', resPipeError);\n                    return resStream.on('end', () => resolve(res));\n                } else {\n                    var buf = Buffer.alloc(0);\n\n                    resStream.on('data', chunk => buf = Buffer.concat([buf, chunk]));\n\n                    var resolver = function (body) {\n                        if (opts.body) {\n                            return resolve(body);\n                        } else {\n                            res.body = body;\n                            return resolve(res);\n                        }\n                    };\n\n                    resStream.on('error', reject);\n\n                    return resStream.on('end', function () {\n                        if (opts.resEncoding) {\n                            let encoding;\n                            if (opts.resEncoding === 'auto') {\n                                encoding = null;\n                                const cType = res.headers['content-type'];\n                                if (/text|javascript|css|json|xml/.test(cType)) {\n                                    encoding = 'utf8';\n                                }\n\n                                if (!opts.autoUnzip && /gzip|deflate/.test(res.headers['content-encoding'])) {\n                                    encoding = null;\n                                }\n                            } else {\n                                encoding = opts.resEncoding;\n                            }\n\n                            const decode = function (buf) {\n                                if (!encoding || !buf) {\n                                    return buf;\n                                }\n                                try {\n                                    if (encoding === 'utf8') {\n                                        return buf.toString();\n                                    } else {\n                                        return kit.requireOptional('iconv-lite', __dirname)\n                                            .decode(buf, encoding);\n                                    }\n                                } catch (err) {\n                                    return reject(err);\n                                }\n                            };\n\n                            return resolver(decode(buf));\n                        } else {\n                            return resolver(buf);\n                        }\n                    });\n                }\n            });\n\n            if (opts.resPipe) {\n                resPipeError = function (err) {\n                    if (opts.resPipeError) {\n                        opts.resPipeError(opts.resPipe);\n                    } else {\n                        opts.resPipe.end();\n                    }\n                    return reject(err);\n                };\n            }\n\n            req.on('error', function (err) {\n                if (opts.resPipe) {\n                    resPipeError(err);\n                }\n                return reject(err);\n            });\n\n            if (opts.timeout > 0) {\n                req.setTimeout(opts.timeout, () => req.emit('error', new Error('timeout')));\n            }\n\n            if (opts.reqPipe) {\n                if (opts.reqProgress) {\n                    (function () {\n                        const total = +opts.headers['content-length'];\n                        let complete = 0;\n                        return opts.reqPipe.on('data', function (chunk) {\n                            complete += chunk.length;\n                            return opts.reqProgress(complete, total);\n                        });\n                    })();\n                }\n\n                return opts.reqPipe.pipe(req);\n            } else {\n                if (opts.autoEndReq) {\n                    return req.end(reqBuf);\n                }\n            }\n        });\n\n        promise.req = req;\n        return promise;\n    },\n\n    /**\n     * The semantic versioner for npm, known as [semver](https://github.com/npm/node-semver).\n     * You must `kit.require 'semver'` before using it.\n     * @type {Object}\n     */\n    semver: null,\n\n    /**\n     * A safer version of `child_process.spawn` to cross-platform run\n     * a process. In some conditions, it may be more convenient\n     * to use the `kit.exec`.\n     * It will automatically add `node_modules/.bin` to the `PATH`\n     * environment variable.\n     * @param  {String} cmd Path or name of an executable program.\n     * @param  {Array} args CLI arguments. If any of the item is an object,\n     * it will be converted to string by `JSON.stringify`.\n     * @param  {Object} opts Process options.\n     * Almost the same with the Node.js official documentation.\n     * It will inherit the parent's stdio by default.\n     * An extra `prefix` option, if it's enabled, all stdout and stderr\n     * will be prefix with the specified string, you can also specify the\n     * color like `web:red`, `web:blue`, if no color found, a random color\n     * will be used.\n     * @return {Promise} The `promise.process` is the spawned child\n     * process object.\n     * **Resolves** when the process's stdio is drained and the exit\n     * code is either `0` or `130`. The resolve value\n     * is like:\n     * ```js\n     * {\n     *  code: 0,\n     *  signal: null\n     * }\n     * ```\n     * @example\n     * ```js\n     * kit.spawn('git', ['commit', '-m', '42 is the answer to everything'])\n     * .then(({code}) => kit.log code);\n     * ```\n     */\n    spawn(cmd, args, opts) {\n        let prefix;\n        if (args == null) {\n            args = [];\n        }\n        if (opts == null) {\n            opts = {};\n        }\n        let PATH = (opts.env && opts.env.PATH) ?\n            opts.env.PATH :\n            process.env.PATH || process.env.Path;\n\n        [\n            kit.path.normalize(__dirname + '/../node_modules/.bin'),\n            kit.path.normalize(process.cwd() + '/node_modules/.bin')\n        ].forEach(function (path) {\n            if ((PATH.indexOf(path) < 0) && kit.fs.existsSync(path)) {\n                return PATH = [path, PATH].join(kit.path.delimiter);\n            }\n        });\n\n        _.defaultsDeep(opts, {\n            stdio: 'inherit',\n            env: process.env\n        });\n\n        opts.env.PATH = PATH;\n\n        if (process.platform === 'win32') {\n            kit.require('whichSync');\n            cmd = kit.whichSync(cmd);\n            if (cmd.slice(-3).toLowerCase() === 'cmd') {\n                const cmdSrc = kit.fs.readFileSync(cmd, 'utf8');\n                const m = cmdSrc.match(/node\\s+\"%~dp0\\\\(\\.\\.\\\\.+)\"/);\n                if (m && m[1]) {\n                    cmd = kit.path.join(cmd, '..', m[1]);\n                    cmd = kit.path.normalize(cmd);\n                    args = [cmd].concat(args);\n                    cmd = 'node';\n                }\n            }\n        }\n\n        const {\n            spawn\n        } = kit.require('child_process', __dirname);\n\n        let ps = null;\n\n        for (let k in args) {\n            const v = args[k];\n            if (_.isObject(v)) {\n                args[k] = JSON.stringify(v);\n            }\n        }\n\n        if (opts.prefix) {\n            let color;\n            const br = kit.require('brush');\n            [prefix, color] = Array.from(opts.prefix.split(':'));\n            if (color) {\n                prefix = br[color](prefix);\n            } else {\n                prefix = br.random(prefix);\n            }\n            prefix += '$&';\n            opts.stdio = [process.stdin, 'pipe', 'pipe'];\n        }\n\n        const promise = new Promise(function (resolve, reject) {\n            try {\n                ps = spawn(cmd, args, opts);\n            } catch (error) {\n                const err = error;\n                reject(err);\n            }\n\n            if (opts.prefix) {\n                const prefixReg = /.*\\n/g;\n                ps.stdout.on('data', d =>\n                    process.stdout.write(\n                        (d + '').replace(prefixReg, prefix)\n                    )\n                );\n                ps.stderr.on('data', d =>\n                    process.stderr.write(\n                        (d + '').replace(prefixReg, prefix)\n                    )\n                );\n            }\n\n            ps.on('error', err => reject(err));\n\n            return ps.on('close', function (code, signal) {\n                if ((code === null) || (code === 0) || (code === 130)) {\n                    return resolve({\n                        code,\n                        signal\n                    });\n                } else {\n                    return reject({\n                        code,\n                        signal\n                    });\n                }\n            });\n        });\n\n        promise.process = ps;\n        return promise;\n    },\n\n    /**\n     * The `sse` module.\n     * You must `kit.require 'sse'` before using it.\n     * For more information goto the `sse` section.\n     */\n    sse: null,\n\n    /**\n     * Sequencing and executing tasks and dependencies concurrently.\n     * @param  {String}   name The task name.\n     * @param  {Object}   opts Optional. Defaults:\n     * ```js\n     * {\n     *  deps: String | Array,\n     *  description: String,\n     *  logStart: () => (),\n     *  logEnd: () => (),\n     *\n     *  // Whether to run dependency in a row.\n     *  isSequential: false\n     * }\n     * ```\n     * @param  {Function} fn `(val) -> Promise | Any` The task function.\n     * If it is a async task, it should return a promise.\n     * It will get its dependency tasks' resolved values.\n     * @property {Function} run Use it to start tasks. Each task will only run once.\n     * `(names = 'default', opts) ->`. The `names` can be a string or array.\n     * The default opts:\n     * ```js\n     * {\n     *  isSequential: false,\n     *\n     *  // Will be passed as the first task's argument.\n     *  init: undefined,\n     *\n     *  // To stop the run currently in process. Set the `$stop`\n     *  // reference to true. It will reject a \"runStopped\" error.\n     *  warp: { $stop: false }\n     * }\n     * ```\n     * @property {Object} list The defined task functions.\n     * @return {Promise} Resolve with the last task's resolved value.\n     * When `isSequential == true`, it resolves a value, else it resolves\n     * an array.\n     * @example\n     * ```js\n     * kit.task('default', { deps: 'build' }, () =>\n     *  kit.log('run defaults...')\n     * );\n     *\n     * kit.task('build', { deps: ['clean'] }, (isFull) =>\n     *  isFull ? 'do something' : 'do something else'\n     * );\n     *\n     * kit.task('clean', (opts) =>\n     *  opts.isForce ?\n     *      kit.remove('dist/**', { isForce: true }) :\n     *      kit.remove('dist/**')\n     * );\n     *\n     * kit.task.run()\n     * .then(() =>\n     *  kit.log('All Done!')\n     * );\n     * ```\n     */\n    task(name, opts, fn) {\n        const br = kit.require('brush');\n        if (_.isFunction(opts)) {\n            fn = opts;\n            opts = {};\n        }\n\n        _.defaults(opts, {\n            isSequential: false,\n            description: '',\n            logStart() {\n                return kit.log(br.cyan('Task Start >> ') +\n                    br.green(`[${name}] `) + this.description\n                );\n            },\n            logEnd() {\n                return kit.log(br.cyan('Task Done >> ') +\n                    br.green(`[${name}] `) + this.description\n                );\n            }\n        });\n\n        if (_.isString(opts.deps)) {\n            opts.deps = [opts.deps];\n        }\n\n        if (kit.task.list == null) {\n            kit.task.list = {};\n        }\n\n        // Here we use some curry functions to deal with the race condition.\n        const runTask = warp => name => function (val) {\n            if (warp[name]) {\n                return warp[name];\n            } else {\n                if (!kit.task.list[name]) {\n                    return Promise.reject(new Error(`task not found: ${name}`));\n                }\n                return warp[name] = kit.task.list[name](warp)(val);\n            }\n        };\n\n        kit.task.list[name] = warp => function (val) {\n            if (warp.$stop) {\n                return Promise.reject(new Error('runStopped'));\n            }\n\n            opts.logStart();\n\n            const p = ((() => {\n                if (!opts.deps || (opts.deps.length < 1)) {\n                    return Promise.resolve(val);\n                } else {\n                    const depTasks = opts.deps.map(runTask(warp));\n\n                    if (opts.isSequential) {\n                        return kit.flow(depTasks)(val);\n                    } else {\n                        return Promise.all(depTasks.map(task => task(val)));\n                    }\n                }\n\n            })()).then(fn);\n            p.then(opts.logEnd.bind(opts));\n            return p;\n        };\n\n        kit.task.list[name].opts = opts;\n\n        return kit.task.run != null ? kit.task.run : (kit.task.run = function (names, opts) {\n            if (names == null) {\n                names = 'default';\n            }\n            if (opts == null) {\n                opts = {};\n            }\n            if (_.isString(names)) {\n                names = [names];\n            }\n\n            _.defaults(opts, {\n                isSequential: false,\n                init: undefined,\n                warp: {\n                    $stop: false\n                }\n            });\n\n            const task = runTask(opts.warp);\n\n            if (opts.isSequential) {\n                return kit.flow(names.map(task))(opts.init);\n            } else {\n                return Promise.all(names.map(name => task(name)(opts.init)));\n            }\n        });\n    },\n\n    /**\n     * Cross-platform kill process tree by root process id.\n     * @param  {Number} pid\n     * @param  {String | Number} signal Such as 'SIGINT'\n     * @param  {Function} callback\n     */\n    treeKill: null,\n\n    /**\n     * The `url` module of node.\n     * You must `kit.require 'url'` before using it.\n     */\n    url: null,\n\n    /**\n     * Works much like `gulp.src`, but with Promise instead.\n     * The warp control and error handling is more pleasant.\n     * @param  {String} from Glob pattern string.\n     * @param  {Object} opts It extends the options of `nofs.glob`, but\n     * with some extra proptereis. Defaults:\n     * ```js\n     * {\n     *  // The base directory of the pattern.\n     *  baseDir: String\n     * }\n     * ```\n     * @return {Object} The returned warp object has these members:\n     * ```js\n     * {\n     *  // The drive can also be a promise that will resolve a drive.\n     *  load: (drive) => fileInfo | null,\n     *\n     *  run: (path) => Promise\n     * }\n     * ```\n     * Each piped drive will recieve a\n     * object that extends `nofs`'s fileInfo object:\n     * ```js\n     * {\n     *  // Set the contents and return self.\n     *  set: (String | Buffer) => fileInfo,\n     *\n     *  // The src file path.\n     *  path: String,\n     *\n     *  // The dest root path.\n     *  to: String,\n     *\n     *  baseDir: String,\n     *\n     *  // The destination path.\n     *  // Alter it if you want to change the output file's location.\n     *  // You can set it to string, warp will auto-convert it to object.\n     *  // It's \"valueOf\" will return \"kit.path.join dir, name + ext\".\n     *  dest: { root, dir, base, ext, name },\n     *\n     *  // The file content.\n     *  contents: String | Buffer,\n     *\n     *  isDir: Boolean,\n     *\n     *  stats: fs.Stats,\n     *\n     *  // Alter it to control the left drives dynamically.\n     *  drives: [Function],\n     *\n     *  // All the globbed files.\n     *  list: Array,\n     *\n     *  driveList: Array,\n     *\n     *  // The opts you passed to \"kit.warp\", it will be extended.\n     *  opts: Object\n     * }\n     * ```\n     *\n     * Each drive can have a `onEnd: (fileInfo) -> Any | Promise` function,\n     * which will be called after a file's whole warp is ended.\n     *\n     * The drive can have a `isReader` property, which will make the drive\n     * override the default file reader.\n     *\n     * The drive can have a `isWriter` property, which will make the drive\n     * override the default file writer.\n     *\n     * If a drive overrides another, it can call `fileInfo.super()` to use it again.\n     * @example\n     * ```js\n     * // Define a simple workflow.\n     * kit.warp('src/**\\/*.js')\n     * .load((fileInfo) =>\n     *     fileInfo.set('/* Lisence Info *\\/' + fileInfo.contents)\n     * )\n     * .load(jslint())\n     * .load(minify())\n     * .run('build/minified');\n     *\n     * // Override warp's file reader with a custom one.\n     * let myReader = kit._.extend((f) =>\n     *     kit.readFile(f.path, 'hex').then(f.path)\n     * ), {\n     *  // This will tell warp you want use your own reader.\n     *  isReader: true\n     * });\n     *\n     * // Override writer.\n     * let myWriter = kit._.extend((f) => {\n     *  if (f.dest === 'a.js') return;\n     *\n     *  // Call the overrided writer.\n     *  f.super();\n     * }, { isWriter: true, onEnd: () => {\n     *    super();\n     *    kit.log(this.list);\n     * });\n     *\n     * kit.warp('src/**\\/*.js')\n     * .load(myWriter)\n     * .run('dist');\n     *\n     * // Use nokit's built-in warp drives.\n     * let drives = kit.require('drives');\n     * kit.warp('src/**\\/*.coffee')\n     * .load(drives.coffee());\n     * .run('dist');\n     * ```\n     */\n    warp(from, opts) {\n        let warpper;\n        if (opts == null) {\n            opts = {};\n        }\n        const drives = kit.require('drives');\n        const driveList = [];\n        let reader = drives.reader();\n        let writer = drives.writer();\n\n        var runDrive = drive => function (info) {\n            const run = function (drive) {\n                if (_.isString(info.dest)) {\n                    info.dest = _.extend(kit.path.parse(info.dest), {\n                        valueOf() {\n                            return kit.path.join(this.dir, this.name + this.ext);\n                        }\n                    });\n                }\n                if (drive.super) {\n                    info.super = () => runDrive(drive.super)(info);\n                }\n\n                return Promise.resolve(drive.call(info, info))\n                    .then(() => info);\n            };\n\n            if (_.isFunction(drive.then)) {\n                return drive.then(run);\n            } else {\n                return run(drive);\n            }\n        };\n\n        const initInfo = function (info) {\n            if (opts.baseDir) {\n                info.baseDir = opts.baseDir;\n            }\n            if (info.path != null) {\n                info.dest = kit.path.join(info.to,\n                    kit.path.relative(info.baseDir, info.path));\n            }\n\n            return _.extend(info, {\n                driveList,\n                opts,\n                set(contents) {\n                    return info.contents = contents;\n                }\n            });\n        };\n\n        return warpper = {\n            load(drive) {\n                if (drive.isReader || drive.isWriter) {\n                    if (drive.isWriter) {\n                        drive.super = writer;\n                        drive.onEnd.super = writer.onEnd;\n                        writer = drive;\n                    }\n                    if (drive.isReader) {\n                        drive.super = reader;\n                        reader = drive;\n                    }\n                } else {\n                    driveList.push(drive);\n                }\n                return warpper;\n            },\n\n            run(to) {\n                if (to == null) {\n                    to = '.';\n                }\n                driveList.unshift(reader);\n                driveList.push(writer);\n\n                const globOpts = _.extend({}, opts, {\n                    iter(info, list) {\n                        list.push(info);\n                        if (opts.baseDir) {\n                            info.baseDir = opts.baseDir;\n                        }\n                        _.extend(info, {\n                            drives: _.clone(driveList),\n                            to,\n                            list\n                        });\n\n                        return kit.flow({\n                            next() {\n                                const drive = info.drives.shift();\n                                return {\n                                    value: drive && runDrive(drive),\n                                    done: !drive\n                                };\n                            }\n                        })(initInfo(info));\n                    }\n                });\n\n                return kit.glob(from, globOpts)\n                    .then(list =>\n                        Promise.all(driveList.map(function (drive) {\n                            if (!drive.onEnd) {\n                                return;\n                            }\n                            return runDrive(drive.onEnd)(initInfo({\n                                to,\n                                list\n                            }));\n                        })));\n            }\n        };\n    },\n\n    /**\n     * Same as the unix `which` command.\n     * You must `kit.require 'which'` before using it.\n     * @param {String} name The command.\n     * @return {Promise}\n     */\n    which: null,\n\n    /**\n     * Sync version of `which`.\n     * You must `kit.require 'whichSync'` before using it.\n     * @type {Function}\n     */\n    whichSync: null,\n\n    /**\n     * For debugging. Dump a colorful object.\n     * @param  {Object} obj Your target object.\n     * @param  {Object} opts Options. Default:\n     * ```js\n     * { colors: true, depth: 7 }\n     * ```\n     * @return {String}\n     */\n    xinspect(obj, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        const util = kit.require('util', __dirname);\n\n        _.defaults(opts, {\n            colors: kit.isDevelopment(),\n            depth: 7\n        });\n\n        return util.inspect(obj, opts);\n    },\n\n    /**\n     * Open a thing that your system can recognize.\n     * Now only support Windows, OSX or system that installed 'xdg-open'.\n     * @param  {String | Array} cmds  The thing you want to open.\n     * @param  {Object} opts The options of the node native\n     * `child_process.exec`.\n     * @return {Promise} When the child process exists.\n     * @example\n     * Open a webpage with the default browser.\n     * ```js\n     * kit.open('http://ysmood.org');\n     * ```\n     */\n    xopen(cmds, opts) {\n        if (opts == null) {\n            opts = {};\n        }\n        const child_process = kit.require('child_process', __dirname);\n\n        if (_.isString(cmds)) {\n            cmds = [cmds];\n        }\n\n        return (Promise.resolve((() => {\n            switch (process.platform) {\n                case 'darwin':\n                    return 'open';\n                case 'win32':\n                    child_process.exec(`start ${cmds.join(' ')}`);\n                    return null;\n                default:\n                    try {\n                        kit.require('whichSync');\n                        return kit.whichSync('xdg-open');\n                    } catch (error) {\n                        return null;\n                    }\n\n            }\n        })())).then(function (starter) {\n            if (!starter) {\n                return;\n            }\n\n            return kit.spawn(starter, cmds);\n        });\n    }\n});\n\nmodule.exports = kit;"]}