Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(repo): format all files #153

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
}
}
}
Loading