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

Add NodeJS-less formatting script #332

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
19 changes: 19 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"indent_size": "2",
"indent_char": " ",
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": false,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_before_conditional": true,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": true,
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false,
"indent_empty_lines": false
}
33 changes: 33 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Ensure path is passed in
if [ -z "$1" ]; then
echo "No argument supplied, please enter the filepath of the xpra-html5 project"

exit 1
fi

# Ensure path passed in is a folder
if [ ! -d "$1" ]; then
echo "$1 either does not exist or is not a folder, please enter the filepath of the xpra-html5 project"

exit 1
fi

# Check if nix is installed, if it isn't, use the determinate nix installer
if command -v nix 2>&1 >/dev/null; then
echo "Nix is installed, formatting..."
else
echo "Nix is not installed, using Determinate Nix Installer..."

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
sh -s -- install

echo "Nix has been installed, formatting..."
fi

nix-shell $1/shell.nix --run "
js-beautify --config $1/.jsbeautifyrc --type js -r $1/html5/js/*.js;
js-beautify --config $1/.jsbeautifyrc --type html -r $1/html5/*.html;
js-beautify --config $1/.jsbeautifyrc --type css -r $1/html5/css/*.css;
"
103 changes: 0 additions & 103 deletions package.json

This file was deleted.

8 changes: 5 additions & 3 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
with (import <nixpkgs> {});
mkShell {
buildInputs = [ nodejs-18_x ];
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { };
in pkgs.mkShell {
buildInputs = with pkgs; [ nodePackages.js-beautify ];
}