Skip to content

Commit

Permalink
fix: Fix install script
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Aug 10, 2024
1 parent 333898d commit a34bdc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ while (( $# )); do
shift
done

if [[ -n "$INIT$UPDATE"]]; then
if [[ -n "$INIT$UPDATE" ]]; then
echo "[@diplodoc/lint] Add initial lint configs"
cp -r "$SRCDIR/scaffolding/" .

Expand All @@ -32,7 +32,7 @@ if [[ -n $INIT ]]; then
echo "[@diplodoc/lint] Extend package.json configuration"
node "$SRCDIR/scripts/modify-package.js"

$BINDIR/husky install
$BINDIR/husky init

exit 0
fi
Expand Down
8 changes: 4 additions & 4 deletions scripts/modify-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ try {
throw 'Unable to modify ' + filename;
}

function configure(command, impl) {
function configure(command, impl, strict = true) {
if (pkg.scripts[command]) {
if (pkg.scripts[command] !== impl) {
if (pkg.scripts[command] !== impl && strict) {
throw `Lint command '${command}' already configured with different program`;
}
} else {
pkg.scripts[command] = impl;
console.log('=> Add', command, 'script');
console.log('[@diplodoc/lint]', '=> Add', command, 'script');
}
}

configure('lint', 'lint init && lint');
configure('lint:fix', 'lint init && lint --fix');
configure('pre-commit', 'lint init && lint-staged');
configure('prepare', 'husky install || true');
configure('prepare', 'husky install || true', false);

writeFileSync(filename, JSON.stringify(pkg, null, 2), 'utf8');

0 comments on commit a34bdc6

Please sign in to comment.