-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #760 from drestrepom/drestrepoatfluid
feat(back): #753.1 add scala formatter
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ Diego Restrepo <[email protected]> Diego Restrepo Mesa <36453706+drest | |
Fluid Attacks <[email protected]> Fluid Attacks <[email protected]> | ||
Github Dependabot <49699333+dependabot[bot]@users.noreply.github.com> dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | ||
Github Octocat <[email protected]> GitHub <[email protected]> | ||
John Perez <[email protected]> John Perez <[email protected]> | ||
Kevin Amado <[email protected]> Kevin Amado <[email protected]> | ||
Luis Saavedra <[email protected]> Luis David Saavedra <[email protected]> | ||
Luis Saavedra <[email protected]> Luis Saavedra <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ __nixpkgs__ | ||
, toBashArray | ||
, makeDerivation | ||
, makeScript | ||
, isDarwin | ||
, fetchUrl | ||
, ... | ||
}: | ||
{ config | ||
, lib | ||
, ... | ||
}: | ||
let | ||
chmodX = name: envSrc: makeDerivation { | ||
env = { inherit envSrc; }; | ||
builder = "cp $envSrc $out && chmod +x $out"; | ||
inherit name; | ||
}; | ||
scalafmt_version = "3.0.8"; | ||
binary_name = if isDarwin then "scalafmt-macos" else "scalafmt-linux-musl"; | ||
binary_file = fetchUrl { | ||
url = "https://github.com/scalameta/scalafmt/releases/download/v${scalafmt_version}/${binary_name}"; | ||
sha256 = "0nxpny86qdbgsmxc9qzsv8f5qb21y25iyr8h2wg61kgiaw8988g0"; | ||
}; | ||
in | ||
{ | ||
options = { | ||
formatScala = { | ||
enable = lib.mkOption { | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
targets = lib.mkOption { | ||
default = [ "/" ]; | ||
type = lib.types.listOf lib.types.str; | ||
}; | ||
}; | ||
}; | ||
config = { | ||
outputs = { | ||
"/formatScala" = lib.mkIf config.formatScala.enable | ||
(makeScript { | ||
replace = { | ||
__argTargets__ = toBashArray | ||
(builtins.map (rel: "." + rel) config.formatJavaScript.targets); | ||
__argScalaFmtBinary__ = chmodX "scalafmt" binary_file; | ||
}; | ||
name = "format-scala"; | ||
entrypoint = ./entrypoint.sh; | ||
}); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# shellcheck shell=bash | ||
|
||
function main { | ||
source __argTargets__/template local targets | ||
|
||
for target in "${targets[@]}"; do | ||
'__argScalaFmtBinary__' "${target}" | ||
done | ||
} | ||
|
||
main "${@}" |