Skip to content

Commit

Permalink
feat: ✨ get (and pre-select) current folder as scope
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrymichel committed Nov 22, 2023
1 parent d932494 commit c4b0518
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ async function loadOptions(config) {
if (config.useFolderScopes) {
const ignores = ['.git', 'node_modules'].concat(config.folderIgnore)
const root = path.resolve(cwd, config.folderRoot)
const { name: currentFolder } = path.parse(cwd)
const folderScopes = fs
.readdirSync(root, { withFileTypes: true })
.filter(
Expand All @@ -177,7 +178,9 @@ async function loadOptions(config) {
!ignores.includes(file.name)
)
.map(file => file.name)

scopes = scopes.concat(folderScopes)
options.currentFolder = currentFolder
}

if (config.useBranchScopes) {
Expand Down Expand Up @@ -247,6 +250,10 @@ function fillPrompt(options) {
type: scopes ? 'list' : 'input',
name: 'scope',
message: 'Specify a scope:',
default:
scopes && scopes.includes(options.currentFolder)
? options.currentFolder
: '',
choices:
scopes &&
[
Expand Down

0 comments on commit c4b0518

Please sign in to comment.