mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
Add pre-commit and ./fmt.sh --test
checks for yarn.lock
file (#18112)
* Add yarn-lock-check pre-commit check * Invoke yarn-lock-check pre-commit check from './fmt.sh --test' * Run yarn-lock-check when yarn.lock changes
This commit is contained in:
parent
da51efa1d1
commit
53372e3795
@ -51,6 +51,12 @@ repos:
|
||||
language: system
|
||||
pass_filenames: false
|
||||
entry: "pre-commit/platform-independence-check.sh"
|
||||
- id: yarn-lock-check
|
||||
name: yarn-lock-check
|
||||
language: system
|
||||
pass_filenames: false
|
||||
files: ^(package.json|yarn.lock)$
|
||||
entry: "pre-commit/yarn-lock-check.sh"
|
||||
- id: mainonly
|
||||
name: main only
|
||||
description: Check for changes under packages with targets tagged with main-only
|
||||
|
7
fmt.sh
7
fmt.sh
@ -129,6 +129,13 @@ echo "\
|
||||
──██────▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌
|
||||
"
|
||||
|
||||
# In 'test' mode, this checks that the 'yarn.lock' file doesn't need any changes.
|
||||
# In 'format' mode, the 'yarn.lock' file will be updated ("formatted") by
|
||||
# 'yarn install' below, if needed.
|
||||
if [[ $is_test = 1 ]]; then
|
||||
run pre-commit run yarn-lock-check
|
||||
fi
|
||||
|
||||
# Make sure the current packages are installed so we can call pprettier
|
||||
# via yarn because calling it via bazel results in very bad performance.
|
||||
run yarn install --silent
|
||||
|
16
pre-commit/yarn-lock-check.sh
Executable file
16
pre-commit/yarn-lock-check.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
TMP_DIR=$(mktemp -d)
|
||||
cp package.json yarn.lock $TMP_DIR
|
||||
|
||||
(cd $TMP_DIR; yarn install --silent > /dev/null)
|
||||
|
||||
if ! diff yarn.lock $TMP_DIR/yarn.lock; then
|
||||
echo "FAIL: yarn.lock could not satisfy package.json" 1>&2
|
||||
echo "FAIL: yarn.lock requires all of the above changes" 1>&2
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue
Block a user