-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(prepare): lookup strategy for Cabal filename (#20)
* fix(prepare): lookup strategy for Cabal filename * fix linter warnings
- Loading branch information
Showing
3 changed files
with
24 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import { PrepareContext } from "semantic-release"; | ||
|
||
import fs from "fs"; | ||
|
||
export const getCabalFilename: () => string | undefined = () => { | ||
return fs | ||
.readdirSync(__dirname) | ||
export function lookupCabalFilename(cwd: string, logger: PrepareContext["logger"]): string { | ||
const cabalFilename = fs | ||
.readdirSync(cwd) | ||
.filter(path => fs.statSync(path).isFile()) | ||
.filter(path => path.endsWith(".cabal")) | ||
.at(0); | ||
}; | ||
|
||
if (!cabalFilename) { | ||
logger.error("Unable to find cabal file name in ", cwd); | ||
throw new Error("Could not determine the cabal filename. Check the plugin configuration"); | ||
} | ||
logger.info("Using cabal file: ", cabalFilename); | ||
|
||
return cabalFilename; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters