Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Allow DS_Store in definitions nested directories #4217

Merged
merged 1 commit into from Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 22 additions & 16 deletions cli/src/lib/npm/npmLibDefs.js
Expand Up @@ -536,22 +536,24 @@ async function getSingleLibdef(
const scope = itemName;
const scopeDirItems = await fs.readdir(itemPath);
const settled = await P.all(
scopeDirItems.map(async itemName => {
const itemPath = path.join(npmDefsDirPath, scope, itemName);
const itemStat = await fs.stat(itemPath);
if (itemStat.isDirectory()) {
return await extractLibDefsFromNpmPkgDir(
itemPath,
scope,
itemName,
validating,
);
} else {
throw new ValidationError(
`Expected only sub-directories in this dir!`,
);
}
}),
scopeDirItems
.filter(item => item !== '.DS_Store')
.map(async itemName => {
const itemPath = path.join(npmDefsDirPath, scope, itemName);
const itemStat = await fs.stat(itemPath);
if (itemStat.isDirectory()) {
return await extractLibDefsFromNpmPkgDir(
itemPath,
scope,
itemName,
validating,
);
} else {
throw new ValidationError(
`Expected only sub-directories in this dir!`,
);
}
}),
);
return [].concat(...settled);
} else {
Expand Down Expand Up @@ -581,6 +583,10 @@ export async function getNpmLibDefs(
const dirItems = await fs.readdir(npmDefsDirPath);
const errors = [];
const proms = dirItems.map(async itemName => {
// If a user opens definitions dir in finder it will create `.DS_Store`
// which will need to be excluded while parsing
if (itemName === '.DS_Store') return;

try {
return await getSingleLibdef(itemName, npmDefsDirPath, validating);
} catch (e) {
Expand Down