mp;& !this.dot) continue // these two cases enter the inGlobStar state var instead = gspref.concat(entries[i], remainWithoutGlobStar); this._process(instead, index, true, cb); var below = gspref.concat(entries[i], remain); this._process(below, index, true, cb); } cb(); }; Glob.prototype._processSimple = function (prefix, index, cb) { // XXX review this. Shouldn't it be doing the mounting etc // before doing stat? kinda weird? var self = this; this._stat(prefix, function (er, exists) { self._processSimple2(prefix, index, er, exists, cb); }); }; Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { //console.error('ps2', prefix, exists) if (!this.matches[index]) this.matches[index] = Object.create(null); // If it doesn't exist, then just mark the lack of results if (!exists) return cb() if (prefix && pathIsAbsolute(prefix) && !this.nomount) { var trail = /[\/\\]$/.test(prefix); if (prefix.charAt(0) === '/') { prefix = path.join(this.root, prefix); } else { prefix = path.resolve(this.root, prefix); if (trail) prefix += '/'; } } if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); // Mark this as a match this._emitMatch(index, prefix); cb(); }; // Returns either 'DIR', 'FILE', or false Glob.prototype._stat = function (f, cb) { var abs = this._makeAbs(f); var needDir = f.slice(-1) === '/'; if (f.length > this.maxLength) return cb() if (!this.stat && ownProp(this.cache, abs)) { var c = this.cache[abs]; if (Array.isArray(c)) c = 'DIR'; // It exists, but maybe not how we need it if (!needDir || c === 'DIR') return cb(null, c) if (needDir && c === 'FILE') return cb() // otherwise we have to stat, because maybe c=true // if we know it exists, but not what it is. } var exists; var stat = this.statCache[abs]; if (stat !== undefined) { if (stat === false) return cb(null, stat) else { var type = stat.isDirectory() ? 'DIR' : 'FILE'; if (needDir && type === 'FILE') return cb() else return cb(null, type, stat) } } var self = this; var statcb = inflight_1('stat\0' + abs, lstatcb_); if (statcb) fs.lstat(abs, statcb); function lstatcb_ (er, lstat) { if (lstat && lstat.isSymbolicLink()) { // If it's a symlink, then treat it as the target, unless // the target does not exist, then treat it as a file. return fs.stat(abs, function (er, stat) { if (er) self._stat2(f, abs, null, lstat, cb); else self._stat2(f, abs, er, stat, cb); }) } else { self._stat2(f, abs, er, lstat, cb); } } }; Glob.prototype._stat2 = function (f, abs, er, stat, cb) { if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { this.statCache[abs] = false; return cb() } var needDir = f.slice(-1) === '/'; this.statCache[abs] = stat; if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat) var c = true; if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE'; this.cache[abs] = this.cache[abs] || c; if (needDir && c === 'FILE') return cb() return cb(null, c, stat) }; var pify_1 = createCommonjsModule(function (module) { 'use strict'; var processFn = function (fn, P, opts) { return function () { var that = this; var args = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) { args[i] = arguments[i]; } return new P(function (resolve, reject) { args.push(function (err, result) { if (err) { reject(err); } else if (opts.multiArgs) { var results = new Array(arguments.length - 1); for (var i = 1; i < arguments.length; i++) { results[i - 1] = arguments[i]; } resolve(results); } else { resolve(result); } }); fn.apply(that, args); }); }; }; var pify = module.exports = function (obj, P, opts) { if (typeof P !== 'function') { opts = P; P = Promise; } opts = opts || {}; opts.exclude = opts.exclude || [/.+Sync$/]; var filter = function (key) { var match = function (pattern) { return typeof pattern === 'string' ? key === pattern : pattern.test(key); }; return opts.include ? opts.include.some(match) : !opts.exclude.some(match); }; var ret = typeof obj === 'function' ? function () { if (opts.excludeMain) { return obj.apply(this, arguments); } return processFn(obj, P, opts).apply(this, arguments); } : {}; return Object.keys(obj).reduce(function (ret, key) { var x = obj[key]; ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x; return ret; }, ret); }; pify.all = pify; }); var globP = pify_1(glob_1, pinkiePromise).bind(glob_1); function isNegative(pattern) { return pattern[0] === '!'; } function isString(value) { return typeof value === 'string'; } function assertPatternsInput(patterns) { if (!patterns.every(isString)) { throw new TypeError('patterns must be a string or an array of strings'); } } function generateGlobTasks(patterns, opts) { patterns = [].concat(patterns); assertPatternsInput(patterns); var globTasks = []; opts = objectAssign({ cache: Object.create(null), statCache: Object.create(null), realpathCache: Object.create(null), symlinks: Object.create(null), ignore: [] }, opts); patterns.forEach(function (pattern, i) { if (isNegative(pattern)) { return; } var ignore = patterns.slice(i).filter(isNegative).map(function (pattern) { return pattern.slice(1); }); globTasks.push({ pattern: pattern, opts: objectAssign({}, opts, { ignore: opts.ignore.concat(ignore) }) }); }); return globTasks; } var globby = function (patterns, opts) { var globTasks; try { globTasks = generateGlobTasks(patterns, opts); } catch (err) { return pinkiePromise.reject(err); } return pinkiePromise.all(globTasks.map(function (task) { return globP(task.pattern, task.opts); })).then(function (paths) { return arrayUnion.apply(null, paths); }); }; var sync$3 = function (patterns, opts) { var globTasks = generateGlobTasks(patterns, opts); return globTasks.reduce(function (matches, task) { return arrayUnion(matches, glob_1.sync(task.pattern, task.opts)); }, []); }; var generateGlobTasks_1 = generateGlobTasks; var hasMagic = function (patterns, opts) { return [].concat(patterns).some(function (pattern) { return glob_1.hasMagic(pattern, opts); }); }; globby.sync = sync$3; globby.generateGlobTasks = generateGlobTasks_1; globby.hasMagic = hasMagic; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ignore = function () { return new IgnoreBase(); }; // A simple implementation of make-array function make_array(subject) { return Array.isArray(subject) ? subject : [subject]; } var REGEX_BLANK_LINE = /^\s+$/; var REGEX_LEADING_EXCAPED_EXCLAMATION = /^\\\!/; var REGEX_LEADING_EXCAPED_HASH = /^\\#/; var SLASH = '/'; var KEY_IGNORE = typeof Symbol !== 'undefined' ? Symbol.for('node-ignore') /* istanbul ignore next */ : 'node-ignore'; var IgnoreBase = function () { function IgnoreBase() { _classCallCheck(this, IgnoreBase); this._rules = []; this[KEY_IGNORE] = true; this._initCache(); } _createClass(IgnoreBase, [{ key: '_initCache', value: function _initCache() { this._cache = {}; } // @param {Array.<string>|string|Ignore} pattern }, { key: 'add', value: function add(pattern) { this._added = false; if (typeof pattern === 'string') { pattern = pattern.split(/\r?\n/g); } make_array(pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore, // making the behavior changed. if (this._added) { this._initCache(); } return this; } // legacy }, { key: 'addPattern', value: function addPattern(pattern) { return this.add(pattern); } }, { key: '_addPattern', value: function _addPattern(pattern) { // #32 if (pattern && pattern[KEY_IGNORE]) { this._rules = this._rules.concat(pattern._rules); this._added = true; return; } if (this._checkPattern(pattern)) { var rule = this._createRule(pattern); this._added = true; this._rules.push(rule); } } }, { key: '_checkPattern', value: function _checkPattern(pattern) { // > A blank line matches no files, so it can serve as a separator for readability. return pattern && typeof pattern === 'string' && !REGEX_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment. && pattern.indexOf('#') !== 0; } }, { key: 'filter', value: function filter(paths) { var _this = this; return make_array(paths).filter(function (path$$1) { return _this._filter(path$$1); }); } }, { key: 'createFilter', value: function createFilter() { var _this2 = this; return function (path$$1) { return _this2._filter(path$$1); }; } }, { key: 'ignores', value: function ignores(path$$1) { return !this._filter(path$$1); } }, { key: '_createRule', value: function _createRule(pattern) { var origin = pattern; var negative = false; // > An optional prefix "!" which negates the pattern; if (pattern.indexOf('!') === 0) { negative = true; pattern = pattern.substr(1); } pattern = pattern // > Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, `"\!important!.txt"`. .replace(REGEX_LEADING_EXCAPED_EXCLAMATION, '!') // > Put a backslash ("\") in front of the first hash for patterns that begin with a hash. .replace(REGEX_LEADING_EXCAPED_HASH, '#'); var regex = make_regex(pattern, negative); return { origin: origin, pattern: pattern, negative: negative, regex: regex }; } // @returns `Boolean` true if the `path` is NOT ignored }, { key: '_filter', value: function _filter(path$$1, slices) { if (!path$$1) { return false; } if (path$$1 in this._cache) { return this._cache[path$$1]; } if (!slices) { // path/to/a.js // ['path', 'to', 'a.js'] slices = path$$1.split(SLASH); } slices.pop(); return this._cache[path$$1] = slices.length // > It is not possible to re-include a file if a parent directory of that file is excluded. // If the path contains a parent directory, check the parent first ? this._filter(slices.join(SLASH) + SLASH, slices) && this._test(path$$1) // Or only test the path : this._test(path$$1); } // @returns {Boolean} true if a file is NOT ignored }, { key: '_test', value: function _test(path$$1) { // Explicitly define variable type by setting matched to `0` var matched = 0; this._rules.forEach(function (rule) { // if matched = true, then we only test negative rules // if matched = false, then we test non-negative rules if (!(matched ^ rule.negative)) { matched = rule.negative ^ rule.regex.test(path$$1); } }); return !matched; } }]); return IgnoreBase; }(); // > If the pattern ends with a slash, // > it is removed for the purpose of the following description, // > but it would only find a match with a directory. // > In other words, foo/ will match a directory foo and paths underneath it, // > but will not match a regular file or a symbolic link foo // > (this is consistent with the way how pathspec works in general in Git). // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`' // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call // you could use option `mark: true` with `glob` // '`foo/`' should not continue with the '`..`' var DEFAULT_REPLACER_PREFIX = [ // > Trailing spaces are ignored unless they are quoted with backslash ("\") [ // (a\ ) -> (a ) // (a ) -> (a) // (a \ ) -> (a ) /\\?\s+$/, function (match) { return match.indexOf('\\') === 0 ? ' ' : ''; }], // replace (\ ) with ' ' [/\\\s/g, function () { return ' '; }], // Escape metacharacters // which is written down by users but means special for regular expressions. // > There are 12 characters with special meanings: // > - the backslash \, // > - the caret ^, // > - the dollar sign $, // > - the period or dot ., // > - the vertical bar or pipe symbol |, // > - the question mark ?, // > - the asterisk or star *, // > - the plus sign +, // > - the opening parenthesis (, // > - the closing parenthesis ), // > - and the opening square bracket [, // > - the opening curly brace {, // > These special characters are often called "metacharacters". [/[\\\^$.|?*+()\[{]/g, function (match) { return '\\' + match; }], // leading slash [ // > A leading slash matches the beginning of the pathname. // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c". // A leading slash matches the beginning of the pathname /^\//, function () { return '^'; }], // replace special metacharacter slash after the leading slash [/\//g, function () { return '\\/'; }], [ // > A leading "**" followed by a slash means match in all directories. // > For example, "**/foo" matches file or directory "foo" anywhere, // > the same as pattern "foo". // > "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo". // Notice that the '*'s have been replaced as '\\*' /^\^*\\\*\\\*\\\//, // '**/foo' <-> 'foo' function () { return '^(?:.*\\/)?'; }]]; var DEFAULT_REPLACER_SUFFIX = [ // starting [ // there will be no leading '/' (which has been replaced by section "leading slash") // If starts with '**', adding a '^' to the regular expression also works /^(?=[^\^])/, function () { return !/\/(?!$)/.test(this) // > If the pattern does not contain a slash /, Git treats it as a shell glob pattern // Actually, if there is only a trailing slash, git also treats it as a shell glob pattern ? '(?:^|\\/)' // > Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) : '^'; }], // two globstars [ // Use lookahead assertions so that we could match more than one `'/**'` /\\\/\\\*\\\*(?=\\\/|$)/g, // Zero, one or several directories // should not use '*', or it will be replaced by the next replacer // Check if it is not the last `'/**'` function (match, index, str) { return index + 6 < str.length // case: /**/ // > A slash followed by two consecutive asterisks then a slash matches zero or more directories. // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on. // '/**/' ? '(?:\\/[^\\/]+)*' // case: /** // > A trailing `"/**"` matches everything inside. // #21: everything inside but it should not include the current folder : '\\/.+'; }], // intermediate wildcards [ // Never replace escaped '*' // ignore rule '\*' will match the path '*' // 'abc.*/' -> go // 'abc.*' -> skip this rule /(^|[^\\]+)\\\*(?=.+)/g, // '*.js' matches '.js' // '*.js' doesn't match 'abc' function (match, p1) { return p1 + '[^\\/]*'; }], // trailing wildcard [/(\^|\\\/)?\\\*$/, function (match, p1) { return (p1 // '\^': // '/*' does not match '' // '/*' does not match everything // '\\\/': // 'abc/*' does not match 'abc/' ? p1 + '[^/]+' // 'a*' matches 'a' // 'a*' matches 'aa' : '[^/]*') + '(?=$|\\/$)'; }], [ // unescape /\\\\\\/g, function () { return '\\'; }]]; var POSITIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [ // 'f' // matches // - /f(end) // - /f/ // - (start)f(end) // - (start)f/ // doesn't match // - oof // - foo // pseudo: // -> (^|/)f(/|$) // ending [ // 'js' will not match 'js.' // 'ab' will not match 'abc' /(?:[^*\/])$/, // 'js*' will not match 'a.js' // 'js/' will not match 'a.js' // 'js' will match 'a.js' and 'a.js/' function (match) { return match + '(?=$|\\/)'; }]], DEFAULT_REPLACER_SUFFIX); var NEGATIVE_REPLACERS = [].concat(DEFAULT_REPLACER_PREFIX, [ // #24 // The MISSING rule of [gitignore docs](https://git-scm.com/docs/gitignore) // A negative pattern without a trailing wildcard should not // re-include the things inside that directory. // eg: // ['node_modules/*', '!node_modules'] // should ignore `node_modules/a.js` [/(?:[^*\/])$/, function (match) { return match + '(?=$|\\/$)'; }]], DEFAULT_REPLACER_SUFFIX); // A simple cache, because an ignore rule only has only one certain meaning var cache = {}; // @param {pattern} function make_regex(pattern, negative) { var r = cache[pattern]; if (r) { return r; } var replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS; var source = replacers.reduce(function (prev, current) { return prev.replace(current[0], current[1].bind(pattern)); }, pattern); return cache[pattern] = new RegExp(source, 'i'); } // Windows // -------------------------------------------------------------- /* istanbul ignore if */ if ( // Detect `process` so that it can run in browsers. typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) { var filter$3 = IgnoreBase.prototype._filter; var make_posix = function make_posix(str) { return (/^\\\\\?\\/.test(str) || /[^\x00-\x80]+/.test(str) ? str : str.replace(/\\/g, '/') ); }; IgnoreBase.prototype._filter = function (path$$1, slices) { path$$1 = make_posix(path$$1); return filter$3.call(this, path$$1, slices); }; } var ansiStyles$3 = createCommonjsModule(function (module) { 'use strict'; const wrapAnsi16 = (fn, offset) => function () { const code = fn.apply(colorConvert, arguments); return `\u001B[${code + offset}m`; }; const wrapAnsi256 = (fn, offset) => function () { const code = fn.apply(colorConvert, arguments); return `\u001B[${38 + offset};5;${code}m`; }; const wrapAnsi16m = (fn, offset) => function () { const rgb = fn.apply(colorConvert, arguments); return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; }; function assembleStyles() { const styles = { modifier: { reset: [0, 0], // 21 isn't widely supported and 22 does the same thing bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], // Bright color redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], // Bright color bgBlackBright: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } }; // Fix humans styles.color.grey = styles.color.gray; Object.keys(styles).forEach(groupName => { const group = styles[groupName]; Object.keys(group).forEach(styleName => { const style = group[styleName]; styles[styleName] = { open: `\u001B[${style[0]}m`, close: `\u001B[${style[1]}m` }; group[styleName] = styles[styleName]; }); Object.defineProperty(styles, groupName, { value: group, enumerable: false }); }); const rgb2rgb = (r, g, b) => [r, g, b]; styles.color.close = '\u001B[39m'; styles.bgColor.close = '\u001B[49m'; styles.color.ansi = {}; styles.color.ansi256 = {}; styles.color.ansi16m = { rgb: wrapAnsi16m(rgb2rgb, 0) }; styles.bgColor.ansi = {}; styles.bgColor.ansi256 = {}; styles.bgColor.ansi16m = { rgb: wrapAnsi16m(rgb2rgb, 10) }; for (const key of Object.keys(colorConvert)) { if (typeof colorConvert[key] !== 'object') { continue; } const suite = colorConvert[key]; if ('ansi16' in suite) { styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); } if ('ansi256' in suite) { styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); } if ('rgb' in suite) { styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); } } return styles; } Object.defineProperty(module, 'exports', { enumerable: true, get: assembleStyles }); }); var supportsColor$3 = createCommonjsModule(function (module) { 'use strict'; const env = process.env; const support = level => { if (level === 0) { return false; } return { level, hasBasic: true, has256: level >= 2, has16m: level >= 3 }; }; let supportLevel = (() => { if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { return 0; } if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) { return 3; } if (hasFlag('color=256')) { return 2; } if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) { return 1; } if (process.stdout && !process.stdout.isTTY) { return 0; } if (process.platform === 'win32') { // Node.js 7.5.0 is the first version of Node.js to include a patch to // libuv that enables 256 color output on Windows. Anything earlier and it // won't work. However, here we target Node.js 8 at minimum as it is an LTS // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows // release that supports 256 colors. const osRelease = os.release().split('.'); if ( Number(process.version.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ) { return 2; } return 1; } if ('CI' in env) { if ('TRAVIS' in env || env.CI === 'Travis' || 'CIRCLECI' in env) { return 1; } return 0; } if ('TEAMCITY_VERSION' in env) { return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; } if ('TERM_PROGRAM' in env) { const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); switch (env.TERM_PROGRAM) { case 'iTerm.app': return version >= 3 ? 3 : 2; case 'Hyper': return 3; case 'Apple_Terminal': return 2; // No default } } if (/^(screen|xterm)-256(?:color)?/.test(env.TERM)) { return 2; } if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(env.TERM)) { return 1; } if ('COLORTERM' in env) { return 1; } if (env.TERM === 'dumb') { return 0; } return 0; })(); if ('FORCE_COLOR' in env) { supportLevel = parseInt(env.FORCE_COLOR, 10) === 0 ? 0 : (supportLevel || 1); } module.exports = process && support(supportLevel); }); var templates$2 = createCommonjsModule(function (module) { 'use strict'; const TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; const ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi; const ESCAPES = { n: '\n', r: '\r', t: '\t', b: '\b', f: '\f', v: '\v', 0: '\0', '\\': '\\', e: '\u001b', a: '\u0007' }; function unescape(c) { if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) { return String.fromCharCode(parseInt(c.slice(1), 16)); } return ESCAPES[c] || c; } function parseArguments(name, args) { const results = []; const chunks = args.trim().split(/\s*,\s*/g); let matches; for (const chunk of chunks) { if (!isNaN(chunk)) { results.push(Number(chunk)); } else if ((matches = chunk.match(STRING_REGEX))) { results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr)); } else { throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); } } return results; } function parseStyle(style) { STYLE_REGEX.lastIndex = 0; const results = []; let matches; while ((matches = STYLE_REGEX.exec(style)) !== null) { const name = matches[1]; if (matches[2]) { const args = parseArguments(name, matches[2]); results.push([name].concat(args)); } else { results.push([name]); } } return results; } function buildStyle(chalk, styles) { const enabled = {}; for (const layer of styles) { for (const style of layer.styles) { enabled[style[0]] = layer.inverse ? null : style.slice(1); } } let current = chalk; for (const styleName of Object.keys(enabled)) { if (Array.isArray(enabled[styleName])) { if (!(styleName in current)) { throw new Error(`Unknown Chalk style: ${styleName}`); } if (enabled[styleName].length > 0) { current = current[styleName].apply(current, enabled[styleName]); } else { current = current[styleName]; } } } return current; } module.exports = (chalk, tmp) => { const styles = []; const chunks = []; let chunk = []; // eslint-disable-next-line max-params tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => { if (escapeChar) { chunk.push(unescape(escapeChar)); } else if (style) { const str = chunk.join(''); chunk = []; chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str)); styles.push({inverse, styles: parseStyle(style)}); } else if (close) { if (styles.length === 0) { throw new Error('Found extraneous } in Chalk template literal'); } chunks.push(buildStyle(chalk, styles)(chunk.join(''))); chunk = []; styles.pop(); } else { chunk.push(chr); } }); chunks.push(chunk.join('')); if (styles.length > 0) { const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; throw new Error(errMsg); } return chunks.join(''); }; }); const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such const skipModels = new Set(['gray']); const styles = Object.create(null); function applyOptions(obj, options) { options = options || {}; // Detect level if not set manually const scLevel = supportsColor$3 ? supportsColor$3.level : 0; obj.level = options.level === undefined ? scLevel : options.level; obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; } function Chalk(options) { // We check for this.template here since calling `chalk.constructor()` // by itself will have a `this` of a previously constructed chalk object if (!this || !(this instanceof Chalk) || this.template) { const chalk = {}; applyOptions(chalk, options); chalk.template = function () { const args = [].slice.call(arguments); return chalkTag.apply(null, [chalk.template].concat(args)); }; Object.setPrototypeOf(chalk, Chalk.prototype); Object.setPrototypeOf(chalk.template, chalk); chalk.template.constructor = Chalk; return chalk.template; } applyOptions(this, options); } // Use bright blue on Windows as the normal blue color is illegible if (isSimpleWindowsTerm) { ansiStyles$3.blue.open = '\u001B[94m'; } for (const key of Object.keys(ansiStyles$3)) { ansiStyles$3[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles$3[key].close), 'g'); styles[key] = { get() { const codes = ansiStyles$3[key]; return build$1.call(this, this._styles ? this._styles.concat(codes) : [codes], key); } }; } ansiStyles$3.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles$3.color.close), 'g'); for (const model of Object.keys(ansiStyles$3.color.ansi)) { if (skipModels.has(model)) { continue; } styles[model] = { get() { const level = this.level; return function () { const open = ansiStyles$3.color[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles$3.color.close, closeRe: ansiStyles$3.color.closeRe }; return build$1.call(this, this._styles ? this._styles.concat(codes) : [codes], model); }; } }; } ansiStyles$3.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles$3.bgColor.close), 'g'); for (const model of Object.keys(ansiStyles$3.bgColor.ansi)) { if (skipModels.has(model)) { continue; } const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); styles[bgModel] = { get() { const level = this.level; return function () { const open = ansiStyles$3.bgColor[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles$3.bgColor.close, closeRe: ansiStyles$3.bgColor.closeRe }; return build$1.call(this, this._styles ? this._styles.concat(codes) : [codes], model); }; } }; } const proto = Object.defineProperties(() => {}, styles); function build$1(_styles, key) { const builder = function () { return applyStyle.apply(builder, arguments); }; builder._styles = _styles; const self = this; Object.defineProperty(builder, 'level', { enumerable: true, get() { return self.level; }, set(level) { self.level = level; } }); Object.defineProperty(builder, 'enabled', { enumerable: true, get() { return self.enabled; }, set(enabled) { self.enabled = enabled; } }); // See below for fix regarding invisible grey/dim combination on Windows builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is // no way to create a function with a different prototype builder.__proto__ = proto; // eslint-disable-line no-proto return builder; } function applyStyle() { // Support varags, but simply cast to string in case there's only one arg const args = arguments; const argsLen = args.length; let str = String(arguments[0]); if (argsLen === 0) { return ''; } if (argsLen > 1) { // Don't slice `arguments`, it prevents V8 optimizations for (let a = 1; a < argsLen; a++) { str += ' ' + args[a]; } } if (!this.enabled || this.level <= 0 || !str) { return str; } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, // see https://github.com/chalk/chalk/issues/58 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. const originalDim = ansiStyles$3.dim.open; if (isSimpleWindowsTerm && this.hasGrey) { ansiStyles$3.dim.open = ''; } for (const code of this._styles.slice().reverse()) { // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen // after next line to fix a bleed issue on macOS // https://github.com/chalk/chalk/pull/92 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue ansiStyles$3.dim.open = originalDim; return str; } function chalkTag(chalk, strings) { if (!Array.isArray(strings)) { // If chalk() was called by itself or with a string, // return the string itself as a string. return [].slice.call(arguments, 1).join(' '); } const args = [].slice.call(arguments, 2); const parts = [strings.raw[0]]; for (let i = 1; i < strings.length; i++) { parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); parts.push(String(strings.raw[i])); } return templates$2(chalk, parts.join('')); } Object.defineProperties(Chalk.prototype, styles); var chalk$2 = Chalk(); // eslint-disable-line new-cap var supportsColor_1 = supportsColor$3; chalk$2.supportsColor = supportsColor_1; var minimist = function (args, opts) { if (!opts) opts = {}; var flags = { bools : {}, strings : {}, unknownFn: null }; if (typeof opts['unknown'] === 'function') { flags.unknownFn = opts['unknown']; } if (typeof opts['boolean'] === 'boolean' && opts['boolean']) { flags.allBools = true; } else { [].concat(opts['boolean']).filter(Boolean).forEach(function (key) { flags.bools[key] = true; }); } var aliases = {}; Object.keys(opts.alias || {}).forEach(function (key) { aliases[key] = [].concat(opts.alias[key]); aliases[key].forEach(function (x) { aliases[x] = [key].concat(aliases[key].filter(function (y) { return x !== y; })); }); }); [].concat(opts.string).filter(Boolean).forEach(function (key) { flags.strings[key] = true; if (aliases[key]) { flags.strings[aliases[key]] = true; } }); var defaults = opts['default'] || {}; var argv = { _ : [] }; Object.keys(flags.bools).forEach(function (key) { setArg(key, defaults[key] === undefined ? false : defaults[key]); }); var notFlags = []; if (args.indexOf('--') !== -1) { notFlags = args.slice(args.indexOf('--')+1); args = args.slice(0, args.indexOf('--')); } function argDefined(key, arg) { return (flags.allBools && /^--[^=]+$/.test(arg)) || flags.strings[key] || flags.bools[key] || aliases[key]; } function setArg (key, val, arg) { if (arg && flags.unknownFn && !argDefined(key, arg)) { if (flags.unknownFn(arg) === false) return; } var value = !flags.strings[key] && isNumber(val) ? Number(val) : val; setKey(argv, key.split('.'), value); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); } function setKey (obj, keys, value) { var o = obj; keys.slice(0,-1).forEach(function (key) { if (o[key] === undefined) o[key] = {}; o = o[key]; }); var key = keys[keys.length - 1]; if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') { o[key] = value; } else if (Array.isArray(o[key])) { o[key].push(value); } else { o[key] = [ o[key], value ]; } } function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; }); } for (var i = 0; i < args.length; i++) { var arg = args[i]; if (/^--.+=/.test(arg)) { // Using [\s\S] instead of . because js doesn't support the // 'dotall' regex modifier. See: // http://stackoverflow.com/a/1068308/13216 var m = arg.match(/^--([^=]+)=([\s\S]*)$/); var key = m[1]; var value = m[2]; if (flags.bools[key]) { value = value !== 'false'; } setArg(key, value, arg); } else if (/^--no-.+/.test(arg)) { var key = arg.match(/^--no-(.+)/)[1]; setArg(key, false, arg); } else if (/^--.+/.test(arg)) { var key = arg.match(/^--(.+)/)[1]; var next = args[i + 1]; if (next !== undefined && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, next, arg); i++; } else if (/^(true|false)$/.test(next)) { setArg(key, next === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } else if (/^-[^-]+/.test(arg)) { var letters = arg.slice(1,-1).split(''); var broken = false; for (var j = 0; j < letters.length; j++) { var next = arg.slice(j+2); if (next === '-') { setArg(letters[j], next, arg); continue; } if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { setArg(letters[j], next.split('=')[1], arg); broken = true; break; } if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { setArg(letters[j], next, arg); broken = true; break; } if (letters[j+1] && letters[j+1].match(/\W/)) { setArg(letters[j], arg.slice(j+2), arg); broken = true; break; } else { setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); } } var key = arg.slice(-1)[0]; if (!broken && key !== '-') { if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) { setArg(key, args[i+1], arg); i++; } else if (args[i+1] && /true|false/.test(args[i+1])) { setArg(key, args[i+1] === 'true', arg); i++; } else { setArg(key, flags.strings[key] ? '' : true, arg); } } } else { if (!flags.unknownFn || flags.unknownFn(arg) !== false) { argv._.push( flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) ); } if (opts.stopEarly) { argv._.push.apply(argv._, args.slice(i + 1)); break; } } } Object.keys(defaults).forEach(function (key) { if (!hasKey(argv, key.split('.'))) { setKey(argv, key.split('.'), defaults[key]); (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), defaults[key]); }); } }); if (opts['--']) { argv['--'] = new Array(); notFlags.forEach(function(key) { argv['--'].push(key); }); } else { notFlags.forEach(function(key) { argv._.push(key); }); } return argv; }; function hasKey (obj, keys) { var o = obj; keys.slice(0,-1).forEach(function (key) { o = (o[key] || {}); }); var key = keys[keys.length - 1]; return key in o; } function isNumber (x) { if (typeof x === 'number') return true; if (/^0x[0-9a-f]+$/i.test(x)) return true; return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x); } const PLACEHOLDER = null; /** * unspecified boolean flag without default value is parsed as `undefined` instead of `false` */ var minimist_1 = function(args, options) { const boolean = options.boolean || []; const defaults = options.default || {}; const booleanWithoutDefault = boolean.filter(key => !(key in defaults)); const newDefaults = Object.assign( {}, defaults, booleanWithoutDefault.reduce( (reduced, key) => Object.assign(reduced, { [key]: PLACEHOLDER }), {} ) ); const parsed = minimist( args, Object.assign({}, options, { default: newDefaults }) ); return Object.keys(parsed).reduce((reduced, key) => { if (parsed[key] !== PLACEHOLDER) { reduced[key] = parsed[key]; } return reduced; }, {}); }; function cleanAST$1(ast, options) { return JSON.stringify(massageAST(ast, options), null, 2); } function massageAST(ast, options, parent) { if (Array.isArray(ast)) { return ast.map(e => massageAST(e, options, parent)).filter(e => e); } if (!ast || typeof ast !== "object") { return ast; } const newObj = {}; for (const key in ast) { if (typeof ast[key] !== "function") { newObj[key] = massageAST(ast[key], options, ast); } } [ "loc", "range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "tokens", "flags", "raws", "sourceIndex", "id", "source", "before", "after", "trailingComma", "parent", "prev", "position" ].forEach(name => { delete newObj[name]; }); if (options.printer.massageAstNode) { const result = options.printer.massageAstNode(ast, newObj, parent); if (result === null) { return undefined; } if (result) { return result; } } return newObj; } var cleanAst = { cleanAST: cleanAST$1, massageAST }; var base = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports['default'] = /*istanbul ignore end*/Diff; function Diff() {} Diff.prototype = { /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) { /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var callback = options.callback; if (typeof options === 'function') { callback = options; options = {}; } this.options = options; var self = this; function done(value) { if (callback) { setTimeout(function () { callback(undefined, value); }, 0); return true; } else { return value; } } // Allow subclasses to massage the input prior to running oldString = this.castInput(oldString); newString = this.castInput(newString); oldString = this.removeEmpty(this.tokenize(oldString)); newString = this.removeEmpty(this.tokenize(newString)); var newLen = newString.length, oldLen = oldString.length; var editLength = 1; var maxEditLength = newLen + oldLen; var bestPath = [{ newPos: -1, components: [] }]; // Seed editLength = 0, i.e. the content starts with the same values var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { // Identity per the equality and tokenizer return done([{ value: this.join(newString), count: newString.length }]); } // Main worker method. checks all permutations of a given edit length for acceptance. function execEditLength() { for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { var basePath = /*istanbul ignore start*/void 0; var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; if (addPath) { // No one else is going to attempt to use this value, clear it bestPath[diagonalPath - 1] = undefined; } var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; if (!canAdd && !canRemove) { // If this path is a terminal then prune bestPath[diagonalPath] = undefined; continue; } // Select the diagonal that we want to branch from. We select the prior // path whose position in the new string is the farthest from the origin // and does not pass the bounds of the diff graph if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { basePath = clonePath(removePath); self.pushComponent(basePath.components, undefined, true); } else { basePath = addPath; // No need to clone, we've pulled it from the list basePath.newPos++; self.pushComponent(basePath.components, true, undefined); } _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); } else { // Otherwise track this path as a potential candidate and continue. bestPath[diagonalPath] = basePath; } } editLength++; } // Performs the length of edit iteration. Is a bit fugly as this has to support the // sync and async mode which is never fun. Loops over execEditLength until a value // is produced. if (callback) { (function exec() { setTimeout(function () { // This should not happen, but we want to be safe. /* istanbul ignore next */ if (editLength > maxEditLength) { return callback(); } if (!execEditLength()) { exec(); } }, 0); })(); } else { while (editLength <= maxEditLength) { var ret = execEditLength(); if (ret) { return ret; } } } }, /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) { var last = components[components.length - 1]; if (last && last.added === added && last.removed === removed) { // We need to clone here as the component clone operation is just // as shallow array clone components[components.length - 1] = { count: last.count + 1, added: added, removed: removed }; } else { components.push({ count: 1, added: added, removed: removed }); } }, /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0; while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { newPos++; oldPos++; commonCount++; } if (commonCount) { basePath.components.push({ count: commonCount }); } basePath.newPos = newPos; return oldPos; }, /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) { return left === right; }, /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) { var ret = []; for (var i = 0; i < array.length; i++) { if (array[i]) { ret.push(array[i]); } } return ret; }, /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) { return value; }, /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) { return value.split(''); }, /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) { return chars.join(''); } }; function buildValues(diff, components, newString, oldString, useLongestToken) { var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0; for (; componentPos < componentLen; componentPos++) { var component = components[componentPos]; if (!component.removed) { if (!component.added && useLongestToken) { var value = newString.slice(newPos, newPos + component.count); value = value.map(function (value, i) { var oldValue = oldString[oldPos + i]; return oldValue.length > value.length ? oldValue : value; }); component.value = diff.join(value); } else { component.value = diff.join(newString.slice(newPos, newPos + component.count)); } newPos += component.count; // Common case if (!component.added) { oldPos += component.count; } } else { component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); oldPos += component.count; // Reverse add and remove so removes are output first to match common convention // The diffing algorithm is tied to add then remove output and this is the simplest // route to get the desired output with minimal overhead. if (componentPos && components[componentPos - 1].added) { var tmp = components[componentPos - 1]; components[componentPos - 1] = components[componentPos]; components[componentPos] = tmp; } } } // Special case handle for when one terminal is ignored. For this case we merge the // terminal into the prior string and drop the change. var lastComponent = components[componentLen - 1]; if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { components[componentLen - 2].value += lastComponent.value; components.pop(); } return components; } function clonePath(path$$1) { return { newPos: path$$1.newPos, components: path$$1.components.slice(0) }; } }); unwrapExports(base); var character = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.characterDiff = undefined; exports. /*istanbul ignore end*/diffChars = diffChars; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'](); function diffChars(oldStr, newStr, callback) { return characterDiff.diff(oldStr, newStr, callback); } }); unwrapExports(character); var params = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports. /*istanbul ignore end*/generateOptions = generateOptions; function generateOptions(options, defaults) { if (typeof options === 'function') { defaults.callback = options; } else if (options) { for (var name in options) { /* istanbul ignore else */ if (options.hasOwnProperty(name)) { defaults[name] = options[name]; } } } return defaults; } }); unwrapExports(params); var word$1 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.wordDiff = undefined; exports. /*istanbul ignore end*/diffWords = diffWords; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); /*istanbul ignore end*/ /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode // // Ranges and exceptions: // Latin-1 Supplement, 0080–00FF // - U+00D7 × Multiplication sign // - U+00F7 ÷ Division sign // Latin Extended-A, 0100–017F // Latin Extended-B, 0180–024F // IPA Extensions, 0250–02AF // Spacing Modifier Letters, 02B0–02FF // - U+02C7 ˇ &#711; Caron // - U+02D8 ˘ &#728; Breve // - U+02D9 ˙ &#729; Dot Above // - U+02DA ˚ &#730; Ring Above // - U+02DB ˛ &#731; Ogonek // - U+02DC ˜ &#732; Small Tilde // - U+02DD ˝ &#733; Double Acute Accent // Latin Extended Additional, 1E00–1EFF var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; var reWhitespace = /\S/; var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'](); wordDiff.equals = function (left, right) { return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); }; wordDiff.tokenize = function (value) { var tokens = value.split(/(\s+|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. for (var i = 0; i < tokens.length - 1; i++) { // If we have an empty string in the next field and we have only word chars before and after, merge if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { tokens[i] += tokens[i + 2]; tokens.splice(i + 1, 2); i--; } } return tokens; }; function diffWords(oldStr, newStr, callback) { var options = /*istanbul ignore start*/(0, params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true }); return wordDiff.diff(oldStr, newStr, options); } function diffWordsWithSpace(oldStr, newStr, callback) { return wordDiff.diff(oldStr, newStr, callback); } }); unwrapExports(word$1); var line$7 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.lineDiff = undefined; exports. /*istanbul ignore end*/diffLines = diffLines; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); /*istanbul ignore end*/ /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'](); lineDiff.tokenize = function (value) { var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line if (!linesAndNewlines[linesAndNewlines.length - 1]) { linesAndNewlines.pop(); } // Merge the content and line separators into single tokens for (var i = 0; i < linesAndNewlines.length; i++) { var line = linesAndNewlines[i]; if (i % 2 && !this.options.newlineIsToken) { retLines[retLines.length - 1] += line; } else { if (this.options.ignoreWhitespace) { line = line.trim(); } retLines.push(line); } } return retLines; }; function diffLines(oldStr, newStr, callback) { return lineDiff.diff(oldStr, newStr, callback); } function diffTrimmedLines(oldStr, newStr, callback) { var options = /*istanbul ignore start*/(0, params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true }); return lineDiff.diff(oldStr, newStr, options); } }); unwrapExports(line$7); var sentence = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.sentenceDiff = undefined; exports. /*istanbul ignore end*/diffSentences = diffSentences; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'](); sentenceDiff.tokenize = function (value) { return value.split(/(\S.+?[.!?])(?=\s+|$)/); }; function diffSentences(oldStr, newStr, callback) { return sentenceDiff.diff(oldStr, newStr, callback); } }); unwrapExports(sentence); var css = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.cssDiff = undefined; exports. /*istanbul ignore end*/diffCss = diffCss; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'](); cssDiff.tokenize = function (value) { return value.split(/([{}:;,]|\s+)/); }; function diffCss(oldStr, newStr, callback) { return cssDiff.diff(oldStr, newStr, callback); } }); unwrapExports(css); var json$1 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.jsonDiff = undefined; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; exports. /*istanbul ignore end*/diffJson = diffJson; /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); /*istanbul ignore end*/ /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/ var objectPrototypeToString = Object.prototype.toString; var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: jsonDiff.useLongestToken = true; jsonDiff.tokenize = /*istanbul ignore start*/line$7.lineDiff. /*istanbul ignore end*/tokenize; jsonDiff.castInput = function (value) { /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement; return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) { if (typeof v === 'undefined') { return undefinedReplacement; } return v; }, ' '); }; jsonDiff.equals = function (left, right) { return (/*istanbul ignore start*/_base2['default']. /*istanbul ignore end*/prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')) ); }; function diffJson(oldObj, newObj, options) { return jsonDiff.diff(oldObj, newObj, options); } // This function handles the presence of circular references by bailing out when encountering an // object that is already on the "stack" of items being processed. function canonicalize(obj, stack, replacementStack) { stack = stack || []; replacementStack = replacementStack || []; var i = /*istanbul ignore start*/void 0; for (i = 0; i < stack.length; i += 1) { if (stack[i] === obj) { return replacementStack[i]; } } var canonicalizedObj = /*istanbul ignore start*/void 0; if ('[object Array]' === objectPrototypeToString.call(obj)) { stack.push(obj); canonicalizedObj = new Array(obj.length); replacementStack.push(canonicalizedObj); for (i = 0; i < obj.length; i += 1) { canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack); } stack.pop(); replacementStack.pop(); return canonicalizedObj; } if (obj && obj.toJSON) { obj = obj.toJSON(); } if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) { stack.push(obj); canonicalizedObj = {}; replacementStack.push(canonicalizedObj); var sortedKeys = [], key = /*istanbul ignore start*/void 0; for (key in obj) { /* istanbul ignore else */ if (obj.hasOwnProperty(key)) { sortedKeys.push(key); } } sortedKeys.sort(); for (i = 0; i < sortedKeys.length; i += 1) { key = sortedKeys[i]; canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack); } stack.pop(); replacementStack.pop(); } else { canonicalizedObj = obj; } return canonicalizedObj; } }); unwrapExports(json$1); var array$1 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.arrayDiff = undefined; exports. /*istanbul ignore end*/diffArrays = diffArrays; /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'](); arrayDiff.tokenize = arrayDiff.join = function (value) { return value.slice(); }; function diffArrays(oldArr, newArr, callback) { return arrayDiff.diff(oldArr, newArr, callback); } }); unwrapExports(array$1); var parse$10 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports. /*istanbul ignore end*/parsePatch = parsePatch; function parsePatch(uniDiff) { /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], list = [], i = 0; function parseIndex() { var index = {}; list.push(index); // Parse diff metadata while (i < diffstr.length) { var line = diffstr[i]; // File header found, end parsing diff metadata if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { break; } // Diff index var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); if (header) { index.index = header[1]; } i++; } // Parse file headers if they are defined. Unified diff requires them, but // there's no technical issues to have an isolated hunk without file header parseFileHeader(index); parseFileHeader(index); // Parse hunks index.hunks = []; while (i < diffstr.length) { var _line = diffstr[i]; if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { break; } else if (/^@@/.test(_line)) { index.hunks.push(parseHunk()); } else if (_line && options.strict) { // Ignore unexpected content unless in strict mode throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); } else { i++; } } } // Parses the --- and +++ headers, if none are found, no lines // are consumed. function parseFileHeader(index) { var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/; var fileHeader = headerPattern.exec(diffstr[i]); if (fileHeader) { var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; index[keyPrefix + 'FileName'] = fileHeader[2]; index[keyPrefix + 'Header'] = fileHeader[3]; i++; } } // Parses a hunk // This assumes that we are at the start of a hunk. function parseHunk() { var chunkHeaderIndex = i, chunkHeaderLine = diffstr[i++], chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); var hunk = { oldStart: +chunkHeader[1], oldLines: +chunkHeader[2] || 1, newStart: +chunkHeader[3], newLines: +chunkHeader[4] || 1, lines: [], linedelimiters: [] }; var addCount = 0, removeCount = 0; for (; i < diffstr.length; i++) { // Lines starting with '---' could be mistaken for the "remove line" operation // But they could be the header for the next file. Therefore prune such cases out. if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { break; } var operation = diffstr[i][0]; if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { hunk.lines.push(diffstr[i]); hunk.linedelimiters.push(delimiters[i] || '\n'); if (operation === '+') { addCount++; } else if (operation === '-') { removeCount++; } else if (operation === ' ') { addCount++; removeCount++; } } else { break; } } // Handle the empty block count case if (!addCount && hunk.newLines === 1) { hunk.newLines = 0; } if (!removeCount && hunk.oldLines === 1) { hunk.oldLines = 0; } // Perform optional sanity checking if (options.strict) { if (addCount !== hunk.newLines) { throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); } if (removeCount !== hunk.oldLines) { throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); } } return hunk; } while (i < diffstr.length) { parseIndex(); } return list; } }); unwrapExports(parse$10); var distanceIterator = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/"use strict"; exports.__esModule = true; exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) { var wantForward = true, backwardExhausted = false, forwardExhausted = false, localOffset = 1; return function iterator() { if (wantForward && !forwardExhausted) { if (backwardExhausted) { localOffset++; } else { wantForward = false; } // Check if trying to fit beyond text length, and if not, check it fits // after offset location (or desired location on first iteration) if (start + localOffset <= maxLine) { return localOffset; } forwardExhausted = true; } if (!backwardExhausted) { if (!forwardExhausted) { wantForward = true; } // Check if trying to fit before text beginning, and if not, check it fits // before offset location if (minLine <= start - localOffset) { return -localOffset++; } backwardExhausted = true; return iterator(); } // We tried to fit hunk before text beginning and beyond text lenght, then // hunk can't fit on the text. Return undefined }; }; }); unwrapExports(distanceIterator); var apply = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports. /*istanbul ignore end*/applyPatch = applyPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches; /*istanbul ignore start*/ var _distanceIterator2 = _interopRequireDefault(distanceIterator); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } /*istanbul ignore end*/function applyPatch(source, uniDiff) { /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; if (typeof uniDiff === 'string') { uniDiff = /*istanbul ignore start*/(0, parse$10.parsePatch) /*istanbul ignore end*/(uniDiff); } if (Array.isArray(uniDiff)) { if (uniDiff.length > 1) { throw new Error('applyPatch only works with a single input.'); } uniDiff = uniDiff[0]; } // Apply the diff to the input var lines = source.split(/\r\n|[\n\v\f\r\x85]/), delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], hunks = uniDiff.hunks, compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{ return (/*istanbul ignore end*/line === patchContent ); }, errorCount = 0, fuzzFactor = options.fuzzFactor || 0, minLine = 0, offset = 0, removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, addEOFNL = /*istanbul ignore start*/void 0; /** * Checks if the hunk exactly fits on the provided location */ function hunkFits(hunk, toPos) { for (var j = 0; j < hunk.lines.length; j++) { var line = hunk.lines[j], operation = line[0], content = line.substr(1); if (operation === ' ' || operation === '-') { // Context sanity check if (!compareLine(toPos + 1, lines[toPos], operation, content)) { errorCount++; if (errorCount > fuzzFactor) { return false; } } toPos++; } } return true; } // Search best fit offsets for each hunk based on the previous ones for (var i = 0; i < hunks.length; i++) { var hunk = hunks[i], maxLine = lines.length - hunk.oldLines, localOffset = 0, toPos = offset + hunk.oldStart - 1; var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine); for (; localOffset !== undefined; localOffset = iterator()) { if (hunkFits(hunk, toPos + localOffset)) { hunk.offset = offset += localOffset; break; } } if (localOffset === undefined) { return false; } // Set lower text limit to end of the current hunk, so next ones don't try // to fit over already patched text minLine = hunk.offset + hunk.oldStart + hunk.oldLines; } // Apply patch hunks for (var _i = 0; _i < hunks.length; _i++) { var _hunk = hunks[_i], _toPos = _hunk.offset + _hunk.newStart - 1; if (_hunk.newLines == 0) { _toPos++; } for (var j = 0; j < _hunk.lines.length; j++) { var line = _hunk.lines[j], operation = line[0], content = line.substr(1), delimiter = _hunk.linedelimiters[j]; if (operation === ' ') { _toPos++; } else if (operation === '-') { lines.splice(_toPos, 1); delimiters.splice(_toPos, 1); /* istanbul ignore else */ } else if (operation === '+') { lines.splice(_toPos, 0, content); delimiters.splice(_toPos, 0, delimiter); _toPos++; } else if (operation === '\\') { var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; if (previousOperation === '+') { removeEOFNL = true; } else if (previousOperation === '-') { addEOFNL = true; } } } } // Handle EOFNL insertion/removal if (removeEOFNL) { while (!lines[lines.length - 1]) { lines.pop(); delimiters.pop(); } } else if (addEOFNL) { lines.push(''); delimiters.push('\n'); } for (var _k = 0; _k < lines.length - 1; _k++) { lines[_k] = lines[_k] + delimiters[_k]; } return lines.join(''); } // Wrapper that supports multiple file patches via callbacks. function applyPatches(uniDiff, options) { if (typeof uniDiff === 'string') { uniDiff = /*istanbul ignore start*/(0, parse$10.parsePatch) /*istanbul ignore end*/(uniDiff); } var currentIndex = 0; function processIndex() { var index = uniDiff[currentIndex++]; if (!index) { return options.complete(); } options.loadFile(index, function (err, data) { if (err) { return options.complete(err); } var updatedContent = applyPatch(data, index, options); options.patched(index, updatedContent, function (err) { if (err) { return options.complete(err); } processIndex(); }); }); } processIndex(); } }); unwrapExports(apply); var create = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports. /*istanbul ignore end*/structuredPatch = structuredPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch; /*istanbul ignore start*/ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { if (!options) { options = {}; } if (typeof options.context === 'undefined') { options.context = 4; } var diff = /*istanbul ignore start*/(0, line$7.diffLines) /*istanbul ignore end*/(oldStr, newStr, options); diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier function contextLines(lines) { return lines.map(function (entry) { return ' ' + entry; }); } var hunks = []; var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1; /*istanbul ignore start*/ var _loop = function _loop( /*istanbul ignore end*/i) { var current = diff[i], lines = current.lines || current.value.replace(/\n$/, '').split('\n'); current.lines = lines; if (current.added || current.removed) { /*istanbul ignore start*/ var _curRange; /*istanbul ignore end*/ // If we have previous context, start with that if (!oldRangeStart) { var prev = diff[i - 1]; oldRangeStart = oldLine; newRangeStart = newLine; if (prev) { curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; oldRangeStart -= curRange.length; newRangeStart -= curRange.length; } } // Output our changes /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) { return (current.added ? '+' : '-') + entry; }))); // Track the updated file position if (current.added) { newLine += lines.length; } else { oldLine += lines.length; } } else { // Identical context lines. Track line changes if (oldRangeStart) { // Close out any changes that have been output (or join overlapping) if (lines.length <= options.context * 2 && i < diff.length - 2) { /*istanbul ignore start*/ var _curRange2; /*istanbul ignore end*/ // Overlapping /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines))); } else { /*istanbul ignore start*/ var _curRange3; /*istanbul ignore end*/ // end the range and output var contextSize = Math.min(lines.length, options.context); /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize)))); var hunk = { oldStart: oldRangeStart, oldLines: oldLine - oldRangeStart + contextSize, newStart: newRangeStart, newLines: newLine - newRangeStart + contextSize, lines: curRange }; if (i >= diff.length - 2 && lines.length <= options.context) { // EOF is inside this hunk var oldEOFNewline = /\n$/.test(oldStr); var newEOFNewline = /\n$/.test(newStr); if (lines.length == 0 && !oldEOFNewline) { // special case: old has no eol and no trailing context; no-nl can end up before adds curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); } else if (!oldEOFNewline || !newEOFNewline) { curRange.push('\\ No newline at end of file'); } } hunks.push(hunk); oldRangeStart = 0; newRangeStart = 0; curRange = []; } } oldLine += lines.length; newLine += lines.length; } }; for (var i = 0; i < diff.length; i++) { /*istanbul ignore start*/ _loop( /*istanbul ignore end*/i); } return { oldFileName: oldFileName, newFileName: newFileName, oldHeader: oldHeader, newHeader: newHeader, hunks: hunks }; } function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); var ret = []; if (oldFileName == newFileName) { ret.push('Index: ' + oldFileName); } ret.push('==================================================================='); ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); for (var i = 0; i < diff.hunks.length; i++) { var hunk = diff.hunks[i]; ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); ret.push.apply(ret, hunk.lines); } return ret.join('\n') + '\n'; } function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); } }); unwrapExports(create); var dmp = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/"use strict"; exports.__esModule = true; exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP; // See: http://code.google.com/p/google-diff-match-patch/wiki/API function convertChangesToDMP(changes) { var ret = [], change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, operation = /*istanbul ignore start*/void 0; for (var i = 0; i < changes.length; i++) { change = changes[i]; if (change.added) { operation = 1; } else if (change.removed) { operation = -1; } else { operation = 0; } ret.push([operation, change.value]); } return ret; } }); unwrapExports(dmp); var xml = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML; function convertChangesToXML(changes) { var ret = []; for (var i = 0; i < changes.length; i++) { var change = changes[i]; if (change.added) { ret.push('<ins>'); } else if (change.removed) { ret.push('<del>'); } ret.push(escapeHTML(change.value)); if (change.added) { ret.push('</ins>'); } else if (change.removed) { ret.push('</del>'); } } return ret.join(''); } function escapeHTML(s) { var n = s; n = n.replace(/&/g, '&amp;'); n = n.replace(/</g, '&lt;'); n = n.replace(/>/g, '&gt;'); n = n.replace(/"/g, '&quot;'); return n; } }); unwrapExports(xml); var lib$5 = createCommonjsModule(function (module, exports) { /*istanbul ignore start*/'use strict'; exports.__esModule = true; exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined; /*istanbul ignore end*/ /*istanbul ignore start*/ var _base2 = _interopRequireDefault(base); /*istanbul ignore end*/ /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } exports. /*istanbul ignore end*/Diff = _base2['default']; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = character.diffChars; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = word$1.diffWords; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = word$1.diffWordsWithSpace; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = line$7.diffLines; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = line$7.diffTrimmedLines; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = sentence.diffSentences; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = css.diffCss; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = json$1.diffJson; /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = array$1.diffArrays; /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = create.structuredPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = create.createTwoFilesPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = create.createPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = apply.applyPatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = apply.applyPatches; /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = parse$10.parsePatch; /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = dmp.convertChangesToDMP; /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = xml.convertChangesToXML; /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = json$1.canonicalize; /* See LICENSE file for terms of use */ /* * Text diff implementation. * * This library supports the following APIS: * JsDiff.diffChars: Character by character diff * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace * JsDiff.diffLines: Line based diff * * JsDiff.diffCss: Diff targeted at CSS content * * These methods are based on the implementation proposed in * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986). * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 */ }); unwrapExports(lib$5); const cleanAST = cleanAst.cleanAST; const getSupportInfo$3 = support.getSupportInfo; const OPTION_USAGE_THRESHOLD = 25; const CHOICE_USAGE_MARGIN = 3; const CHOICE_USAGE_INDENTATION = 2; function getOptions(argv, detailedOptions) { return detailedOptions.filter(option => option.forwardToApi).reduce( (current, option) => Object.assign(current, { [option.forwardToApi]: argv[option.name] }), {} ); } function cliifyOptions(object, apiDetailedOptionMap) { return Object.keys(object || {}).reduce((output, key) => { const apiOption = apiDetailedOptionMap[key]; const cliKey = apiOption ? apiOption.name : key; output[dashify(cliKey)] = object[key]; return output; }, {}); } function diff(a, b) { return lib$5.createTwoFilesPatch("", "", a, b, "", "", { context: 2 }); } function handleError(context, filename, error) { const isParseError = Boolean(error && error.loc); const isValidationError = /Validation Error/.test(error && error.message); // For parse errors and validation errors, we only want to show the error // message formatted in a nice way. `String(error)` takes care of that. Other // (unexpected) errors are passed as-is as a separate argument to // `console.error`. That includes the stack trace (if any), and shows a nice // `util.inspect` of throws things that aren't `Error` objects. (The Flow // parser has mistakenly thrown arrays sometimes.) if (isParseError) { context.logger.error(`${filename}: ${String(error)}`); } else if (isValidationError || error instanceof errors.ConfigError) { context.logger.error(String(error)); // If validation fails for one file, it will fail for all of them. process.exit(1); } else if (error instanceof errors.DebugError) { context.logger.error(`${filename}: ${error.message}`); } else { context.logger.error(filename + ": " + (error.stack || error)); } // Don't exit the process if one file failed process.exitCode = 2; } function logResolvedConfigPathOrDie(context, filePath) { const configFile = resolveConfig_1.resolveConfigFile.sync(filePath); if (configFile) { context.logger.log(path.relative(process.cwd(), configFile)); } else { process.exit(1); } } function writeOutput(result, options) { // Don't use `console.log` here since it adds an extra newline at the end. process.stdout.write(result.formatted); if (options.cursorOffset >= 0) { process.stderr.write(result.cursorOffset + "\n"); } } function listDifferent(context, input, options, filename) { if (!context.argv["list-different"]) { return; } options = Object.assign({}, options, { filepath: filename }); if (!prettier$2.check(input, options)) { if (!context.argv["write"]) { context.logger.log(filename); } process.exitCode = 1; } return true; } function format$1(context, input, opt) { if (context.argv["debug-print-doc"]) { const doc = prettier$2.__debug.printToDoc(input, opt); return { formatted: prettier$2.__debug.formatDoc(doc) }; } if (context.argv["debug-check"]) { const pp = prettier$2.format(input, opt); const pppp = prettier$2.format(pp, opt); if (pp !== pppp) { throw new errors.DebugError( "prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp) ); } else { const normalizedOpts = options$12.normalize(opt); const ast = cleanAST( prettier$2.__debug.parse(input, opt).ast, normalizedOpts ); const past = cleanAST( prettier$2.__debug.parse(pp, opt).ast, normalizedOpts ); if (ast !== past) { const MAX_AST_SIZE = 2097152; // 2MB const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past); throw new errors.DebugError( "ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp) ); } } return { formatted: opt.filepath || "(stdin)\n" }; } return prettier$2.formatWithCursor(input, opt); } function getOptionsOrDie(context, filePath) { try { if (context.argv["config"] === false) { context.logger.debug( "'--no-config' option found, skip loading config file." ); return null; } context.logger.debug( context.argv["config"] ? `load config file from '${context.argv["config"]}'` : `resolve config from '${filePath}'` ); const options = resolveConfig_1.resolveConfig.sync(filePath, { editorconfig: context.argv["editorconfig"], config: context.argv["config"] }); context.logger.debug("loaded options `" + JSON.stringify(options) + "`"); return options; } catch (error) { context.logger.error("Invalid configuration file: " + error.message); process.exit(2); } } function getOptionsForFile(context, filepath) { const options = getOptionsOrDie(context, filepath); const hasPlugins = options && options.plugins; if (hasPlugins) { pushContextPlugins(context, options.plugins); } const appliedOptions = Object.assign( { filepath }, applyConfigPrecedence( context, options && optionsNormalizer.normalizeApiOptions(options, context.supportOptions, { logger: context.logger }) ) ); context.logger.debug( `applied config-precedence (${context.argv["config-precedence"]}): ` + `${JSON.stringify(appliedOptions)}` ); if (hasPlugins) { popContextPlugins(context); } return appliedOptions; } function parseArgsToOptions(context, overrideDefaults) { const minimistOptions = createMinimistOptions(context.detailedOptions); const apiDetailedOptionMap = createApiDetailedOptionMap( context.detailedOptions ); return getOptions( optionsNormalizer.normalizeCliOptions( minimist_1( context.args, Object.assign({ string: minimistOptions.string, boolean: minimistOptions.boolean, default: cliifyOptions(overrideDefaults, apiDetailedOptionMap) }) ), context.detailedOptions, { logger: false } ), context.detailedOptions ); } function applyConfigPrecedence(context, options) { try { switch (context.argv["config-precedence"]) { case "cli-override": return parseArgsToOptions(context, options); case "file-override": return Object.assign({}, parseArgsToOptions(context), options); case "prefer-file": return options || parseArgsToOptions(context); } } catch (error) { context.logger.error(error.toString()); process.exit(2); } } function formatStdin(context) { const filepath = context.argv["stdin-filepath"] ? path.resolve(process.cwd(), context.argv["stdin-filepath"]) : process.cwd(); const ignorer = createIgnorer(context); const relativeFilepath = path.relative(process.cwd(), filepath); thirdParty$1.getStream(process.stdin).then(input => { if (relativeFilepath && ignorer.filter([relativeFilepath]).length === 0) { writeOutput({ formatted: input }, {}); return; } const options = getOptionsForFile(context, filepath); if (listDifferent(context, input, options, "(stdin)")) { return; } try { writeOutput(format$1(context, input, options), options); } catch (error) { handleError(context, "stdin", error); } }); } function createIgnorer(context) { const ignoreFilePath = path.resolve(context.argv["ignore-path"]); let ignoreText = ""; try { ignoreText = fs.readFileSync(ignoreFilePath, "utf8"); } catch (readError) { if (readError.code !== "ENOENT") { context.logger.error( `Unable to read ${ignoreFilePath}: ` + readError.message ); process.exit(2); } } return ignore().add(ignoreText); } function eachFilename(context, patterns, callback) { const ignoreNodeModules = context.argv["with-node-modules"] !== true; if (ignoreNodeModules) { patterns = patterns.concat(["!**/node_modules/**", "!./node_modules/**"]); } try { const filePaths = globby .sync(patterns, { dot: true, nodir: true }) .map(filePath => path.relative(process.cwd(), filePath)); if (filePaths.length === 0) { context.logger.error( `No matching files. Patterns tried: ${patterns.join(" ")}` ); process.exitCode = 2; return; } filePaths.forEach(filePath => callback(filePath, getOptionsForFile(context, filePath)) ); } catch (error) { context.logger.error( `Unable to expand glob patterns: ${patterns.join(" ")}\n${error.message}` ); // Don't exit the process if one pattern failed process.exitCode = 2; } } function formatFiles(context) { // The ignorer will be used to filter file paths after the glob is checked, // before any files are actually written const ignorer = createIgnorer(context); eachFilename(context, context.filePatterns, (filename, options) => { const fileIgnored = ignorer.filter([filename]).length === 0; if ( fileIgnored && (context.argv["write"] || context.argv["list-different"]) ) { return; } if (context.argv["write"] && process.stdout.isTTY) { // Don't use `console.log` here since we need to replace this line. context.logger.log(filename, { newline: false }); } let input; try { input = fs.readFileSync(filename, "utf8"); } catch (error) { // Add newline to split errors from filename line. context.logger.log(""); context.logger.error( `Unable to read file: ${filename}\n${error.message}` ); // Don't exit the process if one file failed process.exitCode = 2; return; } if (fileIgnored) { writeOutput({ formatted: input }, options); return; } listDifferent(context, input, options, filename); const start = Date.now(); let result; let output; try { result = format$1( context, input, Object.assign({}, options, { filepath: filename }) ); output = result.formatted; } catch (error) { // Add newline to split errors from filename line. process.stdout.write("\n"); handleError(context, filename, error); return; } if (context.argv["write"]) { if (process.stdout.isTTY) { // Remove previously printed filename to log it with duration. readline.clearLine(process.stdout, 0); readline.cursorTo(process.stdout, 0, null); } // Don't write the file if it won't change in order not to invalidate // mtime based caches. if (output === input) { if (!context.argv["list-different"]) { context.logger.log(`${chalk$2.grey(filename)} ${Date.now() - start}ms`); } } else { if (context.argv["list-different"]) { context.logger.log(filename); } else { context.logger.log(`${filename} ${Date.now() - start}ms`); } try { fs.writeFileSync(filename, output, "utf8"); } catch (error) { context.logger.error( `Unable to write file: ${filename}\n${error.message}` ); // Don't exit the process if one file failed process.exitCode = 2; } } } else if (context.argv["debug-check"]) { if (output) { context.logger.log(output); } else { process.exitCode = 2; } } else if (!context.argv["list-different"]) { writeOutput(result, options); } }); } function getOptionsWithOpposites(options) { // Add --no-foo after --foo. const optionsWithOpposites = options.map(option => [ option.description ? option : null, option.oppositeDescription ? Object.assign({}, option, { name: `no-${option.name}`, type: "boolean", description: option.oppositeDescription }) : null ]); return flattenArray(optionsWithOpposites).filter(Boolean); } function createUsage(context) { const options = getOptionsWithOpposites(context.detailedOptions).filter( // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag> option => !( option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-") ) ); const groupedOptions = groupBy(options, option => option.category); const firstCategories = constant.categoryOrder.slice(0, -1); const lastCategories = constant.categoryOrder.slice(-1); const restCategories = Object.keys(groupedOptions).filter( category => firstCategories.indexOf(category) === -1 && lastCategories.indexOf(category) === -1 ); const allCategories = firstCategories.concat(restCategories, lastCategories); const optionsUsage = allCategories.map(category => { const categoryOptions = groupedOptions[category] .map(option => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)) .join("\n"); return `${category} options:\n\n${indent$9(categoryOptions, 2)}`; }); return [constant.usageSummary].concat(optionsUsage, [""]).join("\n\n"); } function createOptionUsage(context, option, threshold) { const header = createOptionUsageHeader(option); const optionDefaultValue = getOptionDefaultValue(context, option.name); return createOptionUsageRow( header, `${option.description}${ optionDefaultValue === undefined ? "" : `\nDefaults to ${createDefaultValueDisplay(optionDefaultValue)}.` }`, threshold ); } function createDefaultValueDisplay(value) { return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value; } function createOptionUsageHeader(option) { const name = `--${option.name}`; const alias = option.alias ? `-${option.alias},` : null; const type = createOptionUsageType(option); return [alias, name, type].filter(Boolean).join(" "); } function createOptionUsageRow(header, content, threshold) { const separator = header.length >= threshold ? `\n${" ".repeat(threshold)}` : " ".repeat(threshold - header.length); const description = content.replace(/\n/g, `\n${" ".repeat(threshold)}`); return `${header}${separator}${description}`; } function createOptionUsageType(option) { switch (option.type) { case "boolean": return null; case "choice": return `<${option.choices .filter(choice => !choice.deprecated) .map(choice => choice.value) .join("|")}>`; default: return `<${option.type}>`; } } function flattenArray(array) { return [].concat.apply([], array); } function getOptionWithLevenSuggestion(context, options, optionName) { // support aliases const optionNameContainers = flattenArray( options.map((option, index) => [ { value: option.name, index }, option.alias ? { value: option.alias, index } : null ]) ).filter(Boolean); const optionNameContainer = optionNameContainers.find( optionNameContainer => optionNameContainer.value === optionName ); if (optionNameContainer !== undefined) { return options[optionNameContainer.index]; } const suggestedOptionNameContainer = optionNameContainers.find( optionNameContainer => leven(optionNameContainer.value, optionName) < 3 ); if (suggestedOptionNameContainer !== undefined) { const suggestedOptionName = suggestedOptionNameContainer.value; context.logger.warn( `Unknown option name "${optionName}", did you mean "${suggestedOptionName}"?` ); return options[suggestedOptionNameContainer.index]; } context.logger.warn(`Unknown option name "${optionName}"`); return options.find(option => option.name === "help"); } function createChoiceUsages(choices, margin, indentation) { const activeChoices = choices.filter(choice => !choice.deprecated); const threshold = activeChoices .map(choice => choice.value.length) .reduce((current, length) => Math.max(current, length), 0) + margin; return activeChoices.map(choice => indent$9( createOptionUsageRow(choice.value, choice.description, threshold), indentation ) ); } function createDetailedUsage(context, optionName) { const option = getOptionWithLevenSuggestion( context, getOptionsWithOpposites(context.detailedOptions), optionName ); const header = createOptionUsageHeader(option); const description = `\n\n${indent$9(option.description, 2)}`; const choices = option.type !== "choice" ? "" : `\n\nValid options:\n\n${createChoiceUsages( option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION ).join("\n")}`; const optionDefaultValue = getOptionDefaultValue(context, option.name); const defaults = optionDefaultValue !== undefined ? `\n\nDefault: ${createDefaultValueDisplay(optionDefaultValue)}` : ""; const pluginDefaults = option.pluginDefaults && Object.keys(option.pluginDefaults).length ? `\nPlugin defaults:${Object.keys(option.pluginDefaults).map( key => `\n* ${key}: ${createDefaultValueDisplay( option.pluginDefaults[key] )}` )}` : ""; return `${header}${description}${choices}${defaults}${pluginDefaults}`; } function getOptionDefaultValue(context, optionName) { // --no-option if (!(optionName in context.detailedOptionMap)) { return undefined; } const option = context.detailedOptionMap[optionName]; if (option.default !== undefined) { return option.default; } const optionCamelName = camelcase(optionName); if (optionCamelName in context.apiDefaultOptions) { return context.apiDefaultOptions[optionCamelName]; } return undefined; } function indent$9(str, spaces) { return str.replace(/^/gm, " ".repeat(spaces)); } function groupBy(array, getKey) { return array.reduce((obj, item) => { const key = getKey(item); const previousItems = key in obj ? obj[key] : []; return Object.assign({}, obj, { [key]: previousItems.concat(item) }); }, Object.create(null)); } function pick(object, keys) { return !keys ? object : keys.reduce( (reduced, key) => Object.assign(reduced, { [key]: object[key] }), {} ); } function createLogger(logLevel) { return { warn: createLogFunc("warn", "yellow"), error: createLogFunc("error", "red"), debug: createLogFunc("debug", "blue"), log: createLogFunc("log") }; function createLogFunc(loggerName, color) { if (!shouldLog(loggerName)) { return () => {}; } const prefix = color ? `[${chalk$2[color](loggerName)}] ` : ""; return function(message, opts) { opts = Object.assign({ newline: true }, opts); const stream = process[loggerName === "log" ? "stdout" : "stderr"]; stream.write(message.replace(/^/gm, prefix) + (opts.newline ? "\n" : "")); }; } function shouldLog(loggerName) { switch (logLevel) { case "silent": return false; default: return true; case "debug": if (loggerName === "debug") { return true; } // fall through case "log": if (loggerName === "log") { return true; } // fall through case "warn": if (loggerName === "warn") { return true; } // fall through case "error": return loggerName === "error"; } } } function normalizeDetailedOption(name, option) { return Object.assign({ category: constant.CATEGORY_OTHER }, option, { choices: option.choices && option.choices.map(choice => { const newChoice = Object.assign( { description: "", deprecated: false }, typeof choice === "object" ? choice : { value: choice } ); if (newChoice.value === true) { newChoice.value = ""; // backward compability for original boolean option } return newChoice; }) }); } function normalizeDetailedOptionMap(detailedOptionMap) { return Object.keys(detailedOptionMap) .sort() .reduce((normalized, name) => { const option = detailedOptionMap[name]; return Object.assign(normalized, { [name]: normalizeDetailedOption(name, option) }); }, {}); } function createMinimistOptions(detailedOptions) { return { boolean: detailedOptions .filter(option => option.type === "boolean") .map(option => option.name), string: detailedOptions .filter(option => option.type !== "boolean") .map(option => option.name), default: detailedOptions .filter(option => !option.deprecated) .filter(option => !option.forwardToApi || option.name === "plugin") .filter(option => option.default !== undefined) .reduce( (current, option) => Object.assign({ [option.name]: option.default }, current), {} ), alias: detailedOptions .filter(option => option.alias !== undefined) .reduce( (current, option) => Object.assign({ [option.name]: option.alias }, current), {} ) }; } function createApiDetailedOptionMap(detailedOptions) { return detailedOptions.reduce( (current, option) => option.forwardToApi && option.forwardToApi !== option.name ? Object.assign(current, { [option.forwardToApi]: option }) : current, {} ); } function createDetailedOptionMap(supportOptions) { return supportOptions.reduce((reduced, option) => { const newOption = Object.assign({}, option, { name: option.cliName || dashify(option.name), description: option.cliDescription || option.description, category: option.cliCategory || constant.CATEGORY_FORMAT, forwardToApi: option.name }); if (option.deprecated) { delete newOption.forwardToApi; delete newOption.description; delete newOption.oppositeDescription; newOption.deprecated = true; } return Object.assign(reduced, { [newOption.name]: newOption }); }, {}); } //-----------------------------context-util-start------------------------------- /** * @typedef {Object} Context * @property logger * @property args * @property argv * @property filePatterns * @property supportOptions * @property detailedOptions * @property detailedOptionMap * @property apiDefaultOptions */ function createContext(args) { const context = { args }; updateContextArgv(context); normalizeContextArgv(context, ["loglevel", "plugin"]); context.logger = createLogger(context.argv["loglevel"]); updateContextArgv(context, context.argv["plugin"]); return context; } function initContext(context) { // split into 2 step so that we could wrap this in a `try..catch` in cli/index.js normalizeContextArgv(context); } function updateContextOptions(context, plugins) { const supportOptions = getSupportInfo$3(null, { showDeprecated: true, showUnreleased: true, showInternal: true, plugins }).options; const detailedOptionMap = normalizeDetailedOptionMap( Object.assign({}, createDetailedOptionMap(supportOptions), constant.options) ); const detailedOptions = util$1.arrayify(detailedOptionMap, "name"); const apiDefaultOptions = supportOptions .filter(optionInfo => !optionInfo.deprecated) .reduce( (reduced, optionInfo) => Object.assign(reduced, { [optionInfo.name]: optionInfo.default }), Object.assign({}, options$12.hiddenDefaults) ); context.supportOptions = supportOptions; context.detailedOptions = detailedOptions; context.detailedOptionMap = detailedOptionMap; context.apiDefaultOptions = apiDefaultOptions; } function pushContextPlugins(context, plugins) { context._supportOptions = context.supportOptions; context._detailedOptions = context.detailedOptions; context._detailedOptionMap = context.detailedOptionMap; context._apiDefaultOptions = context.apiDefaultOptions; updateContextOptions(context, plugins); } function popContextPlugins(context) { context.supportOptions = context._supportOptions; context.detailedOptions = context._detailedOptions; context.detailedOptionMap = context._detailedOptionMap; context.apiDefaultOptions = context._apiDefaultOptions; } function updateContextArgv(context, plugins) { pushContextPlugins(context, plugins); const minimistOptions = createMinimistOptions(context.detailedOptions); const argv = minimist_1(context.args, minimistOptions); context.argv = argv; context.filePatterns = argv["_"]; } function normalizeContextArgv(context, keys) { const detailedOptions = !keys ? context.detailedOptions : context.detailedOptions.filter( option => keys.indexOf(option.name) !== -1 ); const argv = !keys ? context.argv : pick(context.argv, keys); context.argv = optionsNormalizer.normalizeCliOptions(argv, detailedOptions, { logger: context.logger }); } //------------------------------context-util-end-------------------------------- var util_1 = { createContext, createDetailedOptionMap, createDetailedUsage, createUsage, format: format$1, formatFiles, formatStdin, initContext, logResolvedConfigPathOrDie, normalizeDetailedOptionMap }; function run(args) { const context = util_1.createContext(args); try { util_1.initContext(context); context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`); if (context.argv["write"] && context.argv["debug-check"]) { context.logger.error("Cannot use --write and --debug-check together."); process.exit(1); } if (context.argv["find-config-path"] && context.filePatterns.length) { context.logger.error("Cannot use --find-config-path with multiple files"); process.exit(1); } if (context.argv["version"]) { context.logger.log(prettier$2.version); process.exit(0); } if (context.argv["help"] !== undefined) { context.logger.log( typeof context.argv["help"] === "string" && context.argv["help"] !== "" ? util_1.createDetailedUsage(context, context.argv["help"]) : util_1.createUsage(context) ); process.exit(0); } if (context.argv["support-info"]) { context.logger.log( prettier$2.format(jsonStableStringify(prettier$2.getSupportInfo()), { parser: "json" }) ); process.exit(0); } const hasFilePatterns = context.filePatterns.length !== 0; const useStdin = context.argv["stdin"] || (!hasFilePatterns && !process.stdin.isTTY); if (context.argv["find-config-path"]) { util_1.logResolvedConfigPathOrDie( context, context.argv["find-config-path"] ); } else if (useStdin) { util_1.formatStdin(context); } else if (hasFilePatterns) { util_1.formatFiles(context); } else { context.logger.log(util_1.createUsage(context)); process.exit(1); } } catch (error) { context.logger.error(error.message); process.exit(1); } } var cli = { run }; cli.run(process.argv.slice(2)); var prettier = { }; module.exports = prettier; Kodo/kodo - Gogs: Go Git Service

1 Commits (adf47f29e6ecbf2bf468b259e4cf82df6eda330e)

Author SHA1 Nachricht Datum
  huangqimin 212f24c882 MarketCode vor 5 Jahren
adminSystem - Gogs: Go Git Service

Nessuna descrizione

FFIB: 11e3a9652a first 7 anni fa
..
src 11e3a9652a first 7 anni fa
index.js 11e3a9652a first 7 anni fa