Skip to content

Commit

Permalink
refactor: code (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed May 14, 2020
1 parent 20c9ae5 commit 045f629
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/preProcessPattern.js
Expand Up @@ -55,24 +55,23 @@ export default async function preProcessPattern(globalRef, pattern) {
`getting stats for '${pattern.absoluteFrom}' to determinate 'fromType'`
);

let stats;

try {
const stats = await stat(inputFileSystem, pattern.absoluteFrom);

if (!stats) {
return pattern;
}

if (stats.isDirectory()) {
pattern.fromType = 'dir';
} else if (stats.isFile()) {
pattern.fromType = 'file';
pattern.stats = stats;
} else if (!pattern.fromType) {
logger.warn(`unrecognized file type for ${pattern.from}`);
}
stats = await stat(inputFileSystem, pattern.absoluteFrom);
} catch (error) {
return pattern;
}

if (stats.isDirectory()) {
pattern.fromType = 'dir';
return pattern;
}

if (stats.isFile()) {
pattern.fromType = 'file';
pattern.stats = stats;
}

return pattern;
}

0 comments on commit 045f629

Please sign in to comment.