Code Monkey home page Code Monkey logo

gsht.sh's Introduction

Global Shell Transpiler

badge

Translations: English - Español

About

gsht is a shell script transpiler that allows you to divide source code in a modular way within a project, to later mix the different files implemented in a single file.

Installation and update

Installation and update script

To install or update gsht, you can download and run the script manually, or I used the following cURL or Wget command:

curl -L https://github.com/NekoOs/gsht.sh/releases/download/nightly/gsht > gsht
wget https://github.com/NekoOs/gsht.sh/releases/download/nightly/gsht

To use gsht globally place the generated file in the binaries directory

sudo mv gsht /usr/local/bin/
sudo chmod a+x /usr/local/bin/gsht

Use

Imagine a structure like this:

/our-project-path
 ├── sub-folder
 │ └── sub-folder
 │ │ └── file-4.sh
 │ └── file-3.sh
 ├── file-1.sh
 └── file-2.sh

Contents of the file /our-project-path/file-1.sh

#!/usr/bin/env bash

echo "file 1 here!"

source ./sub-folder/file-3.sh

Contents of the file /our-project-path/file-2.sh

#!/usr/bin/env bash

echo "file 2 here!"

Contents of the file /our-project-path/sub-folder/file-3.sh

#!/usr/bin/env bash

echo "file 3 here!"

source ./sub-folder/file-4.sh

Contents of the file /our-project-path/sub-folder/sub-folder/file-4.sh

#!/usr/bin/env bash

echo "file 4 here!"

source ../../file-2.sh

Run the following:

gsht /our-project-path/file-1.sh --output = file-1-transpilated

Only the input filename is required gsht source [--output=target]. If the name of the output file has not been specified, the script will default to a name based on the input file, for example above something like this: /our-current-path/file-1

The generated content will be:

#!/usr/bin/env bash

echo "file 1 here!"

echo "file 3 here!"

echo "file 4 here!"

echo "file 2 here!"

Watching Assets For Changes

gsht offers the watch option which will continue to run in your terminal and watch all files re-transpiling automatically:

gsht --watch --input source --output target

Improvements

  • Evaluation of imports with calculated path.
    current_dir=$(dirname "${BASH_SOURCE[0]}")
    source "$current_dir/sub-folder/file.sh"

Tests

./tests/01.sh # generated file ./bin/test-01-transpilated

gsht.sh's People

Contributors

nekoos avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.