Skip to content

Commit

Permalink
chore: fallback parser code style edits
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Feb 20, 2024
1 parent bef8b79 commit 86566ed
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/parser/fallback.js
Expand Up @@ -6,23 +6,23 @@ import isCore from 'is-core-module';
import { resolve as resolveImports } from 'resolve.imports';
import { getContent } from '../utils/file';

const extractPkgName = (value) => {
const [o, n] = value.split('/');
return o[0] === '@' ? `${o}/${n}` : o;
};

const memo = new Map();
const getClosesPkgJson = async (filename) => {
const pkgJsons = new Map();
async function getClosesPkgJson(filename) {
const cwd = path.dirname(filename);
if (memo.has(cwd)) return memo.get(cwd);
if (pkgJsons.has(cwd)) return pkgJsons.get(cwd);

const pkgJson = Promise.resolve(
getContent(findup('package.json', { cwd })).then(JSON.parse),
);
memo.set(cwd, pkgJson);
pkgJsons.set(cwd, pkgJson);

return pkgJson;
};
}

function extractPkgName(value) {
const [o, n] = value.split('/');
return o[0] === '@' ? `${o}/${n}` : o;
}

export async function fallbackParser(filename) {
const ext = path.extname(filename);
Expand Down

0 comments on commit 86566ed

Please sign in to comment.