diff --git a/tools/pre-commit.js b/tools/pre-commit.js index bef6740..1e7c410 100644 --- a/tools/pre-commit.js +++ b/tools/pre-commit.js @@ -1,51 +1,48 @@ #!/usr/bin/env node -const chalk = require('chalk'); -const { execSync } = require('child_process'); +const chalk = require("chalk"); +const { execSync } = require("child_process"); function printErrorAndExit(error) { console.log(error); - console.log(`\n${chalk.red.bold(' Commit failed ')}\n`); + console.log(`\n${chalk.red.bold(" Commit failed ")}\n`); process.exit(1); } -console.log(`\n${chalk.bgGreen.bold(' Validating commit ')}\n`); +console.log(`\n${chalk.bgGreen.bold(" Validating commit ")}\n`); console.log(` > Checking the build`); try { - execSync(`npm run build`, - { - stdio: ['pipe', 'pipe', 'pipe'], - env: { - ...process.env, - FORCE_COLOR: 'true', - }, - } - ); + execSync(`npm run build`, { + stdio: ["pipe", "pipe", "pipe"], + env: { + ...process.env, + FORCE_COLOR: "true", + }, + }); console.log(` ✔ Build successful`); - const result = execSync(`git diff --name-only`, - { - stdio: ['pipe', 'pipe', 'pipe'], - encoding: 'utf-8', - env: { - ...process.env, - FORCE_COLOR: 'true', - }, - } - ); - const changedFiles = result.split('\n').filter(f => f.startsWith('dist/')); + const result = execSync(`git diff --name-only`, { + stdio: ["pipe", "pipe", "pipe"], + encoding: "utf-8", + env: { + ...process.env, + FORCE_COLOR: "true", + }, + }); + const changedFiles = result.split("\n").filter((f) => f.startsWith("dist/")); if (changedFiles.length > 0) { console.log(` > Adding modified build files`); changedFiles.forEach((f) => { execSync(`git add ${f}`, { - stdio: ['pipe', 'pipe', 'pipe'], + stdio: ["pipe", "pipe", "pipe"], }); }); - console.log(` ✔ Commit expanded with ${changedFiles.length} changed file(s)`); + console.log( + ` ✔ Commit expanded with ${changedFiles.length} changed file(s)` + ); } - console.log(`\n${chalk.bold(' Commit successful ')}\n`); + console.log(`\n${chalk.bold(" Commit successful ")}\n`); process.exit(0); - } catch (error) { printErrorAndExit(error); } diff --git a/tsconfig.json b/tsconfig.json index 5282f64..ade24d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,6 @@ "target": "es2015", "module": "commonjs", "moduleResolution": "node", - "types": ["node"], + "types": ["node"] } -} \ No newline at end of file +}