Skip to content

Commit

Permalink
Update package chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Nov 21, 2023
1 parent 0afaef0 commit d0c8cea
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run build && node scripts/check-staged.js
npm run build && node scripts/check-staged.mjs
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ You should do this and commit it before you attempt to `git push`, otherwise the

## Prepush checks

When you push to a branch, git will run a `npm run prepush` [script](scripts/check-staged.js) that will compile the build on your behalf to the `dist/` folder. If it then finds unstaged files in `dist/`, it will fail your push.
When you push to a branch, git will run a `npm run prepush` [script](scripts/check-staged.mjs) that will compile the build on your behalf to the `dist/` folder. If it then finds unstaged files in `dist/`, it will fail your push.

The solution is to commit the files, preferably as part of a separate commit:

Expand Down
114 changes: 104 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"babel-loader": "^8.3.0",
"babel-plugin-istanbul": "^6.1.1",
"chai": "^4.3.10",
"chalk": "^2.4.1",
"chalk": "^5.3.0",
"copy-webpack-plugin": "^6.4.1",
"core-js": "^3.33.3",
"cross-env": "^7.0.3",
Expand Down
8 changes: 5 additions & 3 deletions scripts/check-staged.js → scripts/check-staged.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const cp = require('child_process')
const chalk = require('chalk')
import { exec } from 'node:child_process'
import chalk from 'chalk'

cp.exec('git diff --name-only dist/', (err, stdout) => {
exec('git diff --name-only dist/', (err, stdout) => {
if (err) {
console.log(chalk.red('ERROR:'), err)
return process.exit(1)
}

if (stdout.toString().length) {
console.log(chalk.red('ERROR:'), 'There are unstaged changes in `dist/` after running `npm run build`. Please commit them.')
return process.exit(1)
}

process.exit()
})

0 comments on commit d0c8cea

Please sign in to comment.