Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Internal improvement: Simplify contract-sources's default export #5239

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions packages/contract-sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const { promisify } = require("util");

const DEFAULT_PATTERN = "**/*.{sol,vy,v.py,vyper.py,json,yul}";

module.exports = (pattern, callback) => {
const callbackPassed = typeof callback === "function";
module.exports = async pattern => {
// pattern is either a directory (contracts directory), or an absolute path
// with a glob expression
if (!glob.hasMagic(pattern)) {
Expand All @@ -18,19 +17,5 @@ module.exports = (pattern, callback) => {
dot: true //check hidden files and directories
};

return promisify(glob)(pattern, globOptions)
.then(files => {
if (callbackPassed) {
callback(null, files);
} else {
return files;
}
})
.catch(error => {
if (callbackPassed) {
callback(error);
} else {
throw error;
}
});
return await promisify(glob)(pattern, globOptions);
};