8000 GitHub - Marcisbee/utils: This repo contains various tiny sh utilities.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Marcisbee/utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Various utilities

This repository contains several shell utility scripts designed to facilitate various tasks in your development workflow.

dotenv.sh

The dotenv.sh script loads environment variables from a .env file. This can be particularly useful for setting up your application's configuration in different environments without hardcoding sensitive information into your source code.

Default Usage:

# .env:
# PORT=4000

# test.js:
# console.log(process.env.PORT);

./dotenv.sh -- node ./test.js

or

curl -SsfL https://marcisbee.github.io/utils/dotenv.sh | bash -s -- -- node ./test.js

The script loads the environment variables from .env by default and runs the specified command, in this case, node ./test.js.

Using a Custom Environment File:

If you need to load environment variables from a different file (e.g., for development or testing environments), specify it as follows:

./dotenv.sh .env.development -- node ./test.js

or

curl -SsfL https://marcisbee.github.io/utils/dotenv.sh | bash -s -- .env.development -- node ./test.js

lslint.sh

The lslint.sh script assists in linting the file paths within your project according to rules specified in a .lslint configuration file. This is helpful for maintaining consistency and ensuring that all necessary files adhere to the specified patterns.

Usage:

Create a .lslint configuration file in your project's root directory with the desired file patterns. Here’s an example of how to set it up:

# .lslint
# /package.json
# /node_modules/**/*
# /src/<kebabcase>**/<kebabcase>.<:tsx|ts>
# /src/<kebabcase>**/<kebabcase>.module.css
# /test/**/<kebabcase>.test.ts

./lslint.sh

Before running the script, ensure that the .lslint configuration file exists in your project root directory. Here are some example syntax matches for typical linting patterns:

Pattern Matched File Paths
/file.ts /file.ts
/test/* /test/file.ts, /test/any.css
/test/**/* /test/file.ts, /test/a/b/c/any.css
/test/**/file.ts /test/file.ts, /test/a/file.ts, /test/a/b/c/file.ts
/test/**/*.ts /test/file.ts, /test/a/any.ts, /test/a/b/c/any.ts
/test/start/**/end/*.ts /test/start/end/file.ts, /test/start/a/end/any.ts, ...
/test/**/<kebabcase>.ts /test/paper-bag.ts, /test/a/paper-bag.ts, ...
/test/<kebabcase>**/<kebabcase>.ts /test/paper-bag.ts, ...
/test/<:[A-Z]+>**/mod.<:ts|tsx|css> /test/any.ts, ...

tasks.sh

The tasks.sh script allows you to define and execute shell functions as tasks. These tasks are defined in a separate task.sh file within your project's root directory.

Usage:

./tasks.sh <task_name|task_group>

or

curl -SsfL https://marcisbee.github.io/utils/tasks.sh | bash -s -- <task_name|task_group>
  • Single Task: Execute the function by specifying its name, e.g., ./tasks.sh build.

  • Task Group: Run multiple tasks concurrently by combining their names with a +, e.g., ./tasks.sh build+lint.

Instructions:

  1. Ensure a task.sh file exists in your project's root directory.

  2. Define bash functions prefixed with task_. For example:

    #!/usr/bin/env bash
    
    task_dev() {
      start_task build
      start_task db+server
    }
    
    task_server() {
      echo "Start server process"
    }
    
    task_db() {
      echo "Start db process"
    }
    
    task_build() {
      echo "This is build"
    }
  3. Run the tasks.sh script with the desired task name or group of tasks.

The script includes error handling and cleanup procedures to manage running processes effectively. When combined task names (e.g., build+lint) are provided, each specified task runs concurrently; otherwise, they run sequentially.

Development

For linting shell scripts, use the following command:

curl -SsfL https://marcisbee.github.io/gh/dl.sh | bash -s -- --repo koalaman/shellcheck
./shellcheck lslint.sh

License

MIT © Marcis Bergmanis

About

This repo contains various tiny sh utilities.

Resources

License

Activity 3DDF

Stars

Watchers

Forks

Languages

0