templates: Handle package.json conversion in direnv

By splitting out the check for package.yaml into a separate check, we
can avoid the constant massive shell reloads for the nix shell.
pull/12/head
Tristan Daniël Maat 2022-09-18 19:27:54 +01:00
parent 76f5246814
commit 9fb195819e
Signed by: tlater
GPG Key ID: 49670FD774E43268
3 changed files with 11 additions and 11 deletions

View File

@ -34,17 +34,6 @@
yj
]
++ old.buildInputs;
shellHook =
''
# Update package.json
if [ -e ./package.json ]; then
unlink ./package.json
fi
cat ./package.yaml | yj > ./package.json
''
+ old.shellHook;
});
server = nixpkgs.legacyPackages.${system}.mkShell {

10
templates/.envrc Normal file
View File

@ -0,0 +1,10 @@
nix_direnv_watch_file package-lock.json
use flake ..#templates
# Update package.json
if ! cmp --silent .checksum-package.yaml <(sha256sum package.yaml); then
echo "Updating package.json"
unlink ./package.json
yj < ./package.yaml > ./package.json
sha256sum package.yaml > .checksum-package.yaml
fi

View File

@ -3,3 +3,4 @@ dist/
node_modules/
package.json
result
.checksum-package.yaml