Skip to content

Commit

Permalink
chore(repo): format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed May 28, 2024
1 parent bcc7f3a commit ac08b00
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
53 changes: 25 additions & 28 deletions tools/pre-commit.js
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"types": ["node"],
"types": ["node"]
}
}
}

0 comments on commit ac08b00

Please sign in to comment.