Skip to content

Commit

Permalink
fix(scripts): add validation for current dir
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 3, 2019
1 parent 040cf5d commit 7d14c6f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/scripts/create-textlint-rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = function(projectName, options = {}) {
const ruleName = isInitInCurrentDir
? path.dirname(projectName)
: `textlint-rule-${projectName.replace(/^textlint-rule-/, "")}`;
if (isInitInCurrentDir && !/^textlint-rule-/.test(ruleName)) {
throw new Error(`Current directory name should start with "textlint-rule-<rule-name>".`);
}
const ruleDir = isInitInCurrentDir ? options.cwd : path.join(options.cwd, ruleName);
return spawn(`git`, [
"clone", "--depth=1", "https://github.com/textlint/textlint-rule-template.git",
Expand Down

0 comments on commit 7d14c6f

Please sign in to comment.