Skip to content

Commit 7d14c6f

Browse files
committed
fix(scripts): add validation for current dir
1 parent 040cf5d commit 7d14c6f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/scripts/create-textlint-rule.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ module.exports = function(projectName, options = {}) {
2222
const ruleName = isInitInCurrentDir
2323
? path.dirname(projectName)
2424
: `textlint-rule-${projectName.replace(/^textlint-rule-/, "")}`;
25+
if (isInitInCurrentDir && !/^textlint-rule-/.test(ruleName)) {
26+
throw new Error(`Current directory name should start with "textlint-rule-<rule-name>".`);
27+
}
2528
const ruleDir = isInitInCurrentDir ? options.cwd : path.join(options.cwd, ruleName);
2629
return spawn(`git`, [
2730
"clone", "--depth=1", "https://github.com/textlint/textlint-rule-template.git",

0 commit comments

Comments
 (0)