Skip to content

Commit

Permalink
chore(root): config scopes for git-cz
Browse files Browse the repository at this point in the history
  • Loading branch information
fahchen committed Apr 21, 2024
1 parent c534e98 commit bd05d17
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// commitlint.config.js | .commitlintrc.js
/** @type {import('cz-git').UserConfig} */

const fs = require("fs");
const path = require("path");
const { execSync } = require("child_process");

function* resolveScopes(dir) {
if (fs.existsSync(dir)) {
const entries = fs.readdirSync(dir);
for (entry of entries) {
if (entry.startsWith(".")) continue;
if (fs.lstatSync(path.join(dir, entry)).isDirectory()) {
yield entry;
}
}
}
}

const root_path = execSync("git rev-parse --show-toplevel").toString().trim();

const actions = resolveScopes(path.resolve(root_path, "./"));

const scopes = [...actions, "root"];

module.exports = {
prompt: {
scopes,
},
};

0 comments on commit bd05d17

Please sign in to comment.