Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{frame.map(line => {
// Check if there are any ansi colors/styles
const doubleSpace = line.match(/ {2}/g);
if (ansiRegex().test(line)) {
const newLine = ansiUp.ansi_to_html(line);
return doubleSpace && doubleSpace.length ? (
<div>
) :
<div>;
} else if (doubleSpace && doubleSpace.length) {
return <div>{line}</div>;
}
return <div>{line}</div>;
})}
</div></div>
// Stream output needs to be wrapped in xmp so it
// show literally. Otherwise < chars start a new html element.
mimeType = 'text/html';
isText = true;
isError = false;
renderWithScrollbars = true;
const stream = copy as nbformat.IStream;
const formatted = concatMultilineString(stream.text);
copy.data = {
'text/html': formatted.includes('<') ? `` : `<div>${formatted}</div>`
};
// Output may have goofy ascii colorization chars in it. Try
// colorizing if we don't have html that needs
frame.map(line => {
// Check if there are any ansi colors/styles
if (ansiRegex().test(line)) {
const newLine = ansiUp.ansi_to_html(line);
return <div></div>;
}
return <div>{line}</div>;
})
}
// Stream output needs to be wrapped in xmp so it
// show literally. Otherwise < chars start a new html element.
mimeType = 'text/html';
isText = true;
isError = false;
renderWithScrollbars = true;
const stream = copy as nbformat.IStream;
const formatted = concatMultilineStringOutput(stream.text);
copy.data = {
'text/html': formatted.includes('<') ? `` : `<div>${formatted}</div>`
};
// Output may have goofy ascii colorization chars in it. Try
// colorizing if we don't have html that needs
const divide = data => {
const tester = ansiRegex();
const matcher = /.{1,139}/g;
return data
.split(/\n|\[K|\[[0-9]B|\[[1-9][0-9]B/)
.reduce((arr, line) => {
if (line.length < 140 || line.match(tester)) {
arr.push(line);
} else {
arr.push(...line.match(matcher));
}
return arr;
}, []);
};
tryCatch(async () => {
message = message.replace(ansiRegex(), '');
await fs.appendFileAsync(path, message, 'utf8');
}, err => {
console.error(err);
value = value.replace(regex, chalk.gray('$1'));
} else if (mask === 'expDate') {
value = value.replace(regex, chalk.gray('$1'));
}
const l = chalk.red(label.replace('-', '✖'));
stdout.write(eraseLines(1));
stdout.write(l + value + ansiEscapes.beep);
if (caretOffset) {
process.stdout.write(
ansiEscapes.cursorBackward(Math.abs(caretOffset))
);
}
}
return;
} else if (!ansiRegex().test(data)) {
let tmp =
value.substr(0, value.length + caretOffset) +
data +
value.substr(value.length + caretOffset);
if (mask) {
if (/\d/.test(data) && caretOffset !== 0) {
let formattedData = data;
if (mask === 'cc' || mask === 'ccv') {
formattedData = formatCC(data);
}
if (value[value.length + caretOffset + 1] === ' ') {
tmp =
value.substr(0, value.length + caretOffset) +
const toHumanReadableAnsi = text => {
return text.replace(ansiRegex(), (match, offset, string) => {
switch (match) {
case style.red.close:
case style.green.close:
case style.reset.open:
case style.reset.close:
return '';
case style.red.open:
return '';
case style.green.open:
return '';
case style.dim.open:
return '';
case style.bold.open:
return '';
default:
return '';
import ansiRegex from 'ansi-regex';
import { isUsingYarn } from '@expo/config';
import spawnAsync, { SpawnOptions } from '@expo/spawn-async';
import split from 'split';
import { Transform } from 'stream';
import npmPackageArg from 'npm-package-arg';
import fs from 'fs-extra';
import path from 'path';
import detectIndent from 'detect-indent';
import detectNewline from 'detect-newline';
import log from './log';
const ansi = `(?:${ansiRegex().source})*`;
const npmPeerDependencyWarningPattern = new RegExp(
`${ansi}npm${ansi} ${ansi}WARN${ansi}.+You must install peer dependencies yourself\\.\n`,
'g'
);
const yarnPeerDependencyWarningPattern = new RegExp(
`${ansi}warning${ansi} "[^"]+" has (?:unmet|incorrect) peer dependency "[^"]+"\\.\n`,
'g'
);
class NpmStderrTransform extends Transform {
_transform(
chunk: Buffer,
encoding: string,
callback: (error?: Error | null, data?: any) => void
) {
this.push(chunk.toString().replace(npmPeerDependencyWarningPattern, ''));