Skip to content

Commit

Permalink
Merge pull request #332 from CorbinWunderlich/master
Browse files Browse the repository at this point in the history
Add NodeJS-less formatting script
  • Loading branch information
totaam authored Nov 28, 2024
2 parents ef706d2 + ef14a8d commit df5235d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 106 deletions.
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 ];
}

0 comments on commit df5235d

Please sign in to comment.