Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const main = async (specificationsDirectory: string, profilesDirectory: string) => {
try {
const list = fs.recursiveReaddir(specificationsDirectory);
const specs = [];
let foundMultiApiReadmes = false;
for await (const file of list) {
const f = Path.parse(file);
if (f.base === "readme.enable-multi-api.md") {
foundMultiApiReadmes = true;
const content = (await fs.readFile(file)).toString();
const readMe = cm.parse(content);
const set = new Set();
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"];
if (typeof y === "string") {
set.add(y.replace('$(this-folder)', ''));
} else if (it.isArray(y)) {
for (const i of y) {
let cleanFilePath = i.replace('$(this-folder)', '');
set.add(cleanFilePath);
specs.push(Path.join(f.dir, cleanFilePath));
}
}
const main = async (dir: string) => {
try {
const list = fs.recursiveReaddir(dir)
for await (const file of list) {
const f = path.parse(file)
if (f.base === "readme.md") {
console.log(`processing ${file}`)
const content = (await fs.readFile(file)).toString()
const readMe = cm.parse(content)
const set = new Set()
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"]
if (typeof y === "string") {
set.add(y)
} else if (it.isArray(y)) {
for (const i of y) {
set.add(i)
}
}
}
}