twshim

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 10 Imported by: 0

README

twshim

twshim is a transparent Go wrapper around the standalone Tailwind CSS CLI. The goal of this project is to unify how developers add Tailwind CSS to their Go project by taking care of downloading the executable for the current architecture.

Example

twshim -release v3.2.4 -downloads $HOME/.twshim -- -i in.css -o out.css --minify

Configuration

twshim can be configured through environment variables or command line arguments:

  -downloads string
        Target directory for executables (override TWSHIM_DOWNLOADS)
  -release string
        Tag of the desired release (overrides TWSHIM_RELEASE)

A double dash (--) is required before the Tailwind CSS parameters to distinguish twshim configuration from Tailwind arguments.

twshim uses runtime.GOOS and runtime.GOARCH to decide which executable to download.

See https://github.com/tailwindlabs/tailwindcss/releases for a list of Tailwind releases.

Usage

You can use go run to invoke twshim if you want to quickly execute a specific version of Tailwind CSS CLI.

go run github.com/ngrash/twshim/cmd/twshim@v0.3.0 -release v3.2.4 -downloads $HOME/.twshim/downloads -- --help

You can also use go get to add twshim to your application and use the twshim package from your code.

go get github.com/ngrash/twshim@v0.3.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(downloadRoot, releaseTag, assetName string, arg ...string) (*exec.Cmd, error)

Command returns an exec.Cmd ready for execution. If the binary of the given release does not exist in downloadRoot, it is downloaded first.

func DownloadCLI

func DownloadCLI(tag, asset, dest string) error

DownloadCLI downloads a named asset from a release by tag to the desired destination and makes it executable.

func RuntimeAssetName

func RuntimeAssetName() (string, error)

RuntimeAssetName derives the name of the GitHub asset that holds the tailwindcss standalone CLI binary for the operating system and architecture this func is called on.

Types

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger interface used by twshim to log. Set Log to the desired Logger.

var Log Logger

Log is the Logger used by twshim. If Log = nil, twshim will use a log.Logger by default. To disable logging, set it to log.New(io.Discard, "", 0).

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL