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:
ls bs
,find bs/** -executable
,find bs -type f -executable
, … - see structure:
tree bs
- create folder:
mkdir bs
,mkdir -p bs
,touch README.md
, … - (optional, see below) list commands with commnets:
cat bs/README.md
,bat bs/README.md
, …
- run command:
- using
bs
:- run command:
bs build some-argument
,bs .run build some-argument
- lists commands:
bs
,bs .ls
,bs .ls filter
- see structure:
tree bs
- create folder:
bs .mkdir
- cat README:
bs .cat
,bs .cat filter
- run command:
There are no rules, it is all up to you. But definitely we can put together some suggestions to work with bs more happily.
- prefers short names without unnecessary special characters (spaces, brackets, …)
- provide
--help
options for your scripts - use subdirectories for subtasks
- use dots in names for non-scripts (like
.config.js
,.common.js
,.utils.js
, …) - provide
README.md
to comment your build scripts
bs/
├───build.js
├───build/
│ ├───html.js
│ └───sass.js
├───run.js
├───publish.js
├───.config.js
└───README.md
PS: You can create alias for task with:
ln -rfs bs/target bs/alias
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
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
This feature has been removed in version 0.8.
It seems to be better to use bs/README.md
for comment your build scripts.
See example for current project bs/README.md
.
You can than use cat bs/README.md
to get quick overview of available commands.
See bs.js (line ≥41).
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
via npm - docs for coexistence with others (such as
npm run
)