Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function addDependency(name, container) {
const depEl = doma.one(`
<li>
<a href="https://www.npmjs.com/package/${esc(name)}">
${esc(name)}
</a>
</li>
`);
container.append(depEl);
const {url, description, error} = await fetchPackageInfo(name);
if (error) {
if (error === 'Not found') {
depEl.append(doma('<em>Not published or private.</em>'));
} else {
console.warn(`${errorMessage} fetching ${esc(name)}/package.json`, error);
depEl.append(doma('<em>There was a network error.</em>'));
}
async function addDependency(name, container) {
const depEl = doma.one(`
<li>
<a href="https://www.npmjs.com/package/${esc(name)}">
${esc(name)}
</a>
</li>
`);
container.append(depEl);
const {url, description, error} = await fetchPackageInfo(name);
if (error) {
if (error === 'Not found') {
depEl.append(doma('<em>Not published or private.</em>'));
} else {
console.warn(`${errorMessage} fetching ${esc(name)}/package.json`, error);
depEl.append(doma('<em>There was a network error.</em>'));
}
return;
};
for (const definition in toReplace) {
if (!{}.hasOwnProperty.call(toReplace, definition)) {
continue;
}
const state = toReplace[definition];
if (state) {
title = title.replace(`(${state})`, '');
}
}
if (doEscapeHTML) {
title = escapeGoat.escape(title);
}
return {
content: capitalize(title).trim(),
ref: toReplace.ref
};
};
messageText() {
const escaped = escapeGoat.escape(this.data.text)
return Autolinker.link(this.messageStyling ? fmt(escaped) : escaped, {
className: 'chatLink',
truncate: { length: 50, location: 'smart' }
})
}
}
addHeaderLink(
dependenciesBox,
'npmjs.com',
`https://www.npmjs.com/package/${esc(pkg.name)}`
);
addHeaderLink(
dependenciesBox,
'RunKit',
`https://npm.runkit.com/${esc(pkg.name)}`
);
if (dependencies.length > 0) {
addHeaderLink(
dependenciesBox,
'Visualize full tree',
`http://npm.broofa.com/?q=${esc(pkg.name)}`
);
}
}
}