This is just an extension (backwards compatible) of labaneilers/bs: The simplest possible build system using bash.
Still just simple bash scripts are probably good enough in most cases. However, for some situations it can be useful to use scripts in different language.
This leads to, in root of your project create bs
directory and
put there any executable (chmod +x
+ shellbang):
bs
├───build.js
├───install.sh
├───run
└───test.py
Some shellbangs for example:
#!/usr/bin/env node
#!/usr/bin/env nodejsscript
#!/usr/bin/env -S npx nodejsscript
#!/usr/bin/env python3
#!/usr/bin/env bash
See labaneilers/bs#why.
Your working directory should contain bs
directory with building
scrips/executables. You can use bs
utility with auto-find
feature.
Now you can run and lists your build options like:
- raw:
- Run command:
bs/build.js some-argument
- Lists commands:
find bs -type f -executable
(list help textsgrep -H help bs/.*.toml bs/*/.*.toml
, see below)
- Run command:
- using
bs
:- Run command:
bs build some-argument
- Lists commands:
bs .ls
- Run command:
Now focus on creating building flows. For parallel tasts, you can use this pattern:
#!/usr/bin/env bash
set -eou pipefail
(
trap 'kill 0' SIGINT ;
bs/taskA &
bs/taskB &
bs/taskC &
wait
)
For serial tasks:
#!/usr/bin/env bash
set -eou pipefail
bs/taskA &&
bs/taskB &&
bs/taskC
…pipe tasks:
#!/usr/bin/env bash
set -eou pipefail
cat src/*.js | manipulate > index.js
You can create alias for task with:
ln -rfs bs/target bs/alias
# optionaly
ln -rfs bs/.target.toml bs/.alias.toml
This is just a simple helper providing nice outputs and make some operations easier.
For now for early adapaters.
You can find binaries on Release page.
Or use: npm install https://github.com/jaandrle/bs --location=global
You can create .command.toml
file to describe command
and add additional configuration. Example:
buld.sh
.build.toml
#.build.toml
info= "Description of command"
default= true
[completions]
__all= [ "--help", "--version" ]
cmd= []
…all is optional. But:
info
: this text is listed aside of command name (e.g.bs .ls
)default
: this changes behavior of plainbs
. By default it runs.ls
, now it runs marked commandcompletions
: provide options for completionsbs .run build …
/bs build …
__all
: these options are listed for all sub-commandscmd
: registers sub-command and its possible arguments (bs .run build cmd …
)
See bs.js (line ≥24).
To allow completions just add eval "$(bs .completion bash)"
to your .bashrc
.
You can use Git - Submodules to share your build scrips across your projects.
- provide
bs
binary - some missing? commands in
bs
(maybe.init
) - docs for
.command.toml
(bs
completion) - docs for git submodules to share build scripts
- docs for coexistence with others (such as
npm run
) - examples how to use bash for parallel/serial execution