Skip to content

Commit

Permalink
Merge branch 'main' into bm/format-nodejs-supports-range-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymadden97 committed Jun 25, 2024
2 parents 9adfeb0 + 1835908 commit ae22bf0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkgs/modules/go/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let
};
run-gofmt = pkgs.writeShellApplication {
name = "run-gofmt";
runtimeInputs = [ pkgs.bash ];
runtimeInputs = [ pkgs.bash go ];
extraShellCheckFlags = [ "-x" ];
text = ''
#!/bin/bash
Expand All @@ -30,6 +30,21 @@ let
# Execute the command
gofmt "''${gofmt_args[@]}"
'';
checkPhase = ''
cat > main.go << EOF
package main
func main ( ){
fmt.Println( "hello world" )
}
EOF
$out/bin/run-gofmt -f main.go > output.go
printf 'package main\n\nfunc main() {\n\tfmt.Println("hello world")\n}\n'> expected.go
if ! diff expected.go output.go; then
echo "format output doesn't match expectation"
exit 1
fi
'';
};

in
Expand Down
11 changes: 11 additions & 0 deletions pkgs/modules/nodejs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ let
# Resolve to first prettier in path
prettier "''${prettier_args[@]}"
'';
checkPhase = ''
cat > index.ts << EOF
function foo() { return 10}
EOF
$out/bin/run-prettier -f index.ts > output.ts
printf 'function foo() {\n\treturn 10;\n}\n'> expected.ts
if ! diff expected.ts output.ts; then
echo "format output doesn't match expectation"
exit 1
fi
'';
};


Expand Down

0 comments on commit ae22bf0

Please sign in to comment.