mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-03-02 17:30:18 +00:00
Added shfmt
This commit is contained in:
71
shfmt/README.md
Normal file
71
shfmt/README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: shfmt
|
||||
homepage: https://github.com/mvdan/sh
|
||||
tagline: |
|
||||
shfmt: Format shell programs
|
||||
---
|
||||
|
||||
To update or switch versions, run `webi shfmt@stable` or `webi shfmt@beta`, etc.
|
||||
|
||||
# Cheat Sheet
|
||||
|
||||
> shfmt is a shell parser, formatter and interpretter that supports POSIX Shell, Bash and mksh.
|
||||
|
||||
Usage: `shfmt <flags> <filepath>`
|
||||
|
||||
Note: If given path is directory, all shell scripts in the directory will be used.
|
||||
|
||||
## Flags:
|
||||
|
||||
*-version*
|
||||
Show version and exit.
|
||||
|
||||
*-l*
|
||||
List files whose formatting differs from shfmt's.
|
||||
|
||||
*-w*
|
||||
Write result to file instead of stdout.
|
||||
|
||||
*-d*
|
||||
Error with a diff when the formatting differs.
|
||||
|
||||
*-s*
|
||||
Simplify the code.
|
||||
|
||||
*-mn*
|
||||
Minify the code to reduce its size (implies -s).
|
||||
|
||||
*-ln* <str>
|
||||
Language variant to parse (bash/posix/mksh/bats, default "bash").
|
||||
|
||||
*-p*
|
||||
Shorthand for -ln=posix.
|
||||
|
||||
*-filename* str
|
||||
Provide a name for the standard input file.
|
||||
|
||||
*-i* <uint>
|
||||
Indent: 0 for tabs (default), >0 for number of spaces.
|
||||
|
||||
*-bn*
|
||||
Binary ops like && and | may start a line.
|
||||
|
||||
*-ci*
|
||||
Switch cases will be indented.
|
||||
|
||||
*-sr*
|
||||
Redirect operators will be followed by a space.
|
||||
|
||||
*-kp*
|
||||
Keep column alignment paddings.
|
||||
|
||||
*-fn*
|
||||
Function opening braces are placed on a separate line.
|
||||
|
||||
*-f*
|
||||
Recursively find all shell files and print the paths.
|
||||
|
||||
*-tojson*
|
||||
Print syntax tree to stdout as a typed JSON.
|
||||
|
||||
See https://github.com/mvdan/sh for more info.
|
||||
46
shfmt/install.ps1
Normal file
46
shfmt/install.ps1
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
##################
|
||||
# Install shfmt #
|
||||
##################
|
||||
|
||||
$pkg_cmd_name = "shfmt"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\shfmt.exe"
|
||||
$pkg_dst = "$pkg_dst_cmd"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\shfmt-v$Env:WEBI_VERSION\bin\shfmt.exe"
|
||||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\shfmt-v$Env:WEBI_VERSION\bin"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\shfmt-v$Env:WEBI_VERSION"
|
||||
$pkg_src = "$pkg_src_cmd"
|
||||
|
||||
$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
|
||||
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
|
||||
{
|
||||
echo "Downloading shfmt from $Env:WEBI_PKG_URL to $pkg_download"
|
||||
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
|
||||
& move "$pkg_download.part" "$pkg_download"
|
||||
}
|
||||
|
||||
IF (!(Test-Path -Path "$pkg_src_cmd"))
|
||||
{
|
||||
echo "Installing shfmt"
|
||||
pushfmtd .local\tmp
|
||||
|
||||
Remove-Item -Path ".\shfmt-v*" -Recurse -ErrorAction Ignore
|
||||
Remove-Item -Path ".\shfmt.exe" -Recurse -ErrorAction Ignore
|
||||
|
||||
echo "Unpacking $pkg_download"
|
||||
& tar xf "$pkg_download"
|
||||
|
||||
echo "Install Location: $pkg_src_cmd"
|
||||
New-Item "$pkg_src_bin" -ItemType Directory -Force
|
||||
Move-Item -Path ".\shfmt-*\shfmt.exe" -Destination "$pkg_src_bin"
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
|
||||
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore
|
||||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||
30
shfmt/install.sh
Normal file
30
shfmt/install.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
{
|
||||
set -e
|
||||
set -u
|
||||
|
||||
##################
|
||||
# Install shfmt #
|
||||
##################
|
||||
|
||||
pkg_cmd_name="shfmt"
|
||||
|
||||
pkg_dst_cmd="$HOME/.local/bin/shfmt"
|
||||
pkg_dst="$pkg_dst_cmd"
|
||||
|
||||
pkg_src_cmd="$HOME/.local/opt/shfmt-v$WEBI_VERSION/bin/shfmt"
|
||||
pkg_src_dir="$HOME/.local/opt/shfmt-v$WEBI_VERSION"
|
||||
pkg_src="$pkg_src_cmd"
|
||||
|
||||
pkg_install() {
|
||||
# ~/.local/opt/shfmt-v0.99.9/bin
|
||||
mkdir -p "$(dirname $pkg_src_cmd)"
|
||||
mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
|
||||
}
|
||||
|
||||
pkg_get_current_version() {
|
||||
echo $(shfmt --version 2>/dev/null | head -n 1 | cut -d ' ' -f 2)
|
||||
}
|
||||
|
||||
}
|
||||
19
shfmt/releases.js
Normal file
19
shfmt/releases.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var github = require('../_common/github.js');
|
||||
var owner = 'mvdan';
|
||||
var repo = 'sh';
|
||||
|
||||
module.exports = function(request) {
|
||||
return github(request, owner, repo).then(function(all) {
|
||||
return all;
|
||||
});
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
module.exports(require('@root/request')).then(function(all) {
|
||||
all = require('../_webi/normalize.js')(all);
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user