Skip to content

Commit

Permalink
fix build with npm
Browse files Browse the repository at this point in the history
  • Loading branch information
gmichelo committed Feb 1, 2024
1 parent 4a4b8dd commit c1636b0
Showing 1 changed file with 9 additions and 134 deletions.
143 changes: 9 additions & 134 deletions dist/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4459,139 +4459,6 @@ function parseParams (str) {
module.exports = parseParams


/***/ }),

/***/ 3715:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const {splitByIndex, splitByLineAndChar} = __nccwpck_require__(8250);

/**
* List of regexes matching errors for unexpected characters after JSON data
*
* First placeholder: line number, 1-indexed
* Second placeholder: character number, 1-indexed
* Third placeholder: overall character index, 0-indexed
*/
const ERROR_REGEXES = [
/^()()Unexpected .* in JSON at position (\d+)$/, // Node 8..18, Chrome 69
/^()()Unexpected non-whitespace character after JSON at position (\d+)$/, // Chromium 113
/^JSON.parse: unexpected non-whitespace character after JSON data at line (\d+) column (\d+) of the JSON data()$/, // Firefox 62
];

/**
* Parse a string of multiple JSON objects/values
*
* @param {string} input String with zero or more JSON objects/values in series,
* possibly separated by whitespace
* @param {Object} [options] Options:
* @param {boolean} [options.partial] Don't throw an error if the input ends
* partway through an object/value. Instead
* add a property `remainder` to the returned
* array with the remaining partial JSON
* string. Default: false
* @param {string[]} [acc] Accumulator for internal use
* @returns {(Object|Array|string|number|boolean|null)[]} Array of results
*/
function jsonMultiParse(input, options = {}, acc = []) {
if (options.partial) {
acc.remainder = '';
}

if (input.trim().length === 0) {
return acc;
}

try {
acc.push(JSON.parse(input));
return acc;
} catch (error) {
let match = null;
for (const regex of ERROR_REGEXES) {
if (match = error.message.match(regex)) {
break;
}
}
if (!match) {
if (options.partial) {
acc.remainder = input;
return acc;
}
throw error;
}

const chunks = match[3]
? splitByIndex(input, parseInt(match[3], 10))
: splitByLineAndChar(input, parseInt(match[1], 10) - 1, parseInt(match[2], 10) - 1);

acc.push(JSON.parse(chunks[0]));
return jsonMultiParse(chunks[1], options, acc);
}
}

module.exports = jsonMultiParse;


/***/ }),

/***/ 8250:
/***/ ((module) => {

/**
* Split a string by character index
*
* @param {string} input
* @param {number} index Character index, 0-indexed
* @returns {string[]} The two output chunks
*/
function splitByIndex(input, index) {
if (index < 0 || index >= input.length) {
throw new Error(`Character index ${index} out of range`);
}
return [input.substr(0, index), input.substr(index)];
}

/**
* Split a string by line index and character index
*
* @param {string} input
* @param {number} lineIndex Line index, 0-indexed
* @param {number} charIndex Character index, 0-indexed
* @returns {string[]} The two output chunks
*/
function splitByLineAndChar(input, lineIndex, charIndex) {
if (lineIndex < 0) {
throw new Error(`Line index ${lineIndex} out of range`);
}
if (charIndex < 0) {
throw new Error(`Character index ${charIndex} out of range`);
}

// Find the start of the line we are interested in
let lineStartIndex = 0;
for (let l = lineIndex; l > 0; l--) {
lineStartIndex = input.indexOf('\n', lineStartIndex);
if (lineStartIndex === -1) {
throw new Error(`Line index ${lineIndex} out of range`);
}
lineStartIndex++;
}

// Check the character number we want is within this line
const nextNl = input.indexOf('\n', lineStartIndex);
if (lineStartIndex + charIndex >= input.length || nextNl !== -1 && nextNl <= lineStartIndex + charIndex) {
throw new Error(`Character index ${charIndex} out of range for line ${lineIndex}`);
}

return splitByIndex(input, lineStartIndex + charIndex);
}

module.exports = {
splitByIndex,
splitByLineAndChar,
};


/***/ }),

/***/ 4294:
Expand Down Expand Up @@ -26844,6 +26711,14 @@ function version(uuid) {
var _default = version;
exports["default"] = _default;

/***/ }),

/***/ 5865:
/***/ ((module) => {

module.exports = eval("require")("json-multi-parse");


/***/ }),

/***/ 9491:
Expand Down Expand Up @@ -27294,7 +27169,7 @@ async function resolveCacheMode(cacheMode) {
{ mountTarget: pnpmCache, framework: cacheMode },
];
const json = await getExecStdout("pnpm m ls --depth -1 --json");
const jsonMultiParse = __nccwpck_require__(3715);
const jsonMultiParse = __nccwpck_require__(5865);
const parsed = jsonMultiParse(json);
for (const list of parsed) {
for (const entry of list) {
Expand Down

0 comments on commit c1636b0

Please sign in to comment.