Skip to content

Commit

Permalink
dist: build new artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Korthout <korthout@users.noreply.github.com>
  • Loading branch information
korthout committed Aug 15, 2023
1 parent 7f34f87 commit 15b4541
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 42 deletions.
96 changes: 55 additions & 41 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5666,50 +5666,64 @@ module.exports = resolveCommand;
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = dedent;
function dedent(strings, ...values) {
const raw = typeof strings === "string" ? [strings] : strings.raw;

// first, perform interpolation
let result = "";
for (let i = 0; i < raw.length; i++) {
result += raw[i]
// join lines when there is a suppressed newline
.replace(/\\\n[ \t]*/g, "")
// handle escaped backticks
.replace(/\\`/g, "`");
if (i < values.length) {
result += values[i];
}
}

// now strip indentation
const lines = result.split("\n");
let mindent = null;
for (const l of lines) {
const m = l.match(/^(\s+)\S+/);
if (m) {
const indent = m[1].length;
if (!mindent) {
// this is the first indented line
mindent = indent;
} else {
mindent = Math.min(mindent, indent);
exports["default"] = void 0;
var _default = createDedent({});
exports["default"] = _default;
function createDedent(options) {
dedent.withOptions = newOptions => createDedent({
...options,
...newOptions
});
return dedent;
function dedent(strings, ...values) {
const raw = typeof strings === "string" ? [strings] : strings.raw;
const {
escapeSpecialCharacters = Array.isArray(strings)
} = options;

// first, perform interpolation
let result = "";
for (let i = 0; i < raw.length; i++) {
let next = raw[i];
if (escapeSpecialCharacters) {
// handle escaped newlines, backticks, and interpolation characters
next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\{/g, "{");
}
result += next;
if (i < values.length) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
result += values[i];
}
}

// now strip indentation
const lines = result.split("\n");
let mindent = null;
for (const l of lines) {
const m = l.match(/^(\s+)\S+/);
if (m) {
const indent = m[1].length;
if (!mindent) {
// this is the first indented line
mindent = indent;
} else {
mindent = Math.min(mindent, indent);
}
}
}
if (mindent !== null) {
const m = mindent; // appease TypeScript
result = lines
// https://github.com/typescript-eslint/typescript-eslint/issues/7140
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
.map(l => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join("\n");
}
return result
// dedent eats leading and trailing whitespace too
.trim()
// handle escaped newlines at the end to ensure they don't get stripped too
.replace(/\\n/g, "\n");
}
if (mindent !== null) {
const m = mindent; // appease TypeScript
result = lines
// https://github.com/typescript-eslint/typescript-eslint/issues/7140
// eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
.map(l => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join("\n");
}
return result
// dedent eats leading and trailing whitespace too
.trim()
// handle escaped newlines at the end to ensure they don't get stripped too
.replace(/\\n/g, "\n");
}
module.exports = exports.default;
module.exports["default"] = exports.default;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit 15b4541

Please sign in to comment.