No video

Replacing make with a Shell Script for Running Your Project's Tasks

  Рет қаралды 5,073

Nick Janetakis

Nick Janetakis

Күн бұрын

I'm enjoying this shell script set up to replace a Makefile that's being used as a glorified aliases file.
Hit the subscribe button to receive more videos like this!
REFERENCE LINKS
---------------------------------------------------
► github.com/nic...
► gist.github.co... (Makefile)
► github.com/adr...
COURSES
---------------------------------------------------
Courses I've created that focus on web dev and deployment topics.
► nickjanetakis....
THE TOOLS I USE / GEAR
---------------------------------------------------
► nickjanetakis....
FOLLOW ME ELSEWHERE
---------------------------------------------------
► Twitter: / nickjanetakis
► GitHub: github.com/nickjj
TIMESTAMPS
---------------------------------------------------
0:00 -- What we're going to cover in this video
0:49 -- A basic Makefile, using .PHONY and controlling output
5:12 -- The main reason why I switched from a Makefile to a shell script
7:35 -- Taking a look at a run script that replaces a Makefile
8:14 -- A quick comparison between a shell function and make task
9:19 -- Using $@ to pass arguments from a command into the script
10:27 -- Creating shell functions without arguments
11:07 -- Namespacing shell functions with a colon to group up commands
11:31 -- Creating private functions to use as helpers in public commands
13:14 -- A couple of useful functions you might want in a web application
14:51 -- Figuring out this shell script pattern from a Taskfile project on GitHub
15:34 -- Creating a run alias so you don't need to type ./ every time
16:24 -- Adding in the idea of having private functions
16:54 -- Auto generating a help menu with printf, compgen, grep and cat
20:34 -- Using time or eval to convert arguments into runnable functions
22:48 -- Any questions? I'm happy to answer them in the comments below

Пікірлер: 19
@farzadmf
@farzadmf 3 жыл бұрын
One thing to note about make is that it supports targets being dependent on each other. When running a target, this would allow skipping re-running all the dependencies if they haven't changed, and that's what I think is missing when using a script.
@NickJanetakis
@NickJanetakis 3 жыл бұрын
Yep. I tried to call that out early on about how you'll probably want to stick with make if you're compiling dependencies with C.
@farzadmf
@farzadmf 3 жыл бұрын
I wouldn't say it's only for C, I think make has grown much more than its initial intention. I've seen it used in Go projects as well
@NickJanetakis
@NickJanetakis 3 жыл бұрын
@@farzadmf Yeah, that was mainly just 1 example. The video's focus is for when you're basically creating aliases, not compiling code.
@farzadmf
@farzadmf 3 жыл бұрын
Absolutely, don't get me wrong. This wasn't to say the video isn't good. I love your videos and watch every single one of them. This was just to point out the edge cases as we developers always do 😉
@NickJanetakis
@NickJanetakis 3 жыл бұрын
@@farzadmf It's all good!
@chadlowe6622
@chadlowe6622 3 жыл бұрын
Great video. I am currently using a Make file I lifted from someone else's example code, but this feels much cleaner and more flexible to me. Time to make a switch.
@NickJanetakis
@NickJanetakis 3 жыл бұрын
Thanks. That's usually what I end up doing too. Lift -> use -> attempt to tweak things for the better based on personal requirements / needs.
@JAUN320
@JAUN320 3 жыл бұрын
@@NickJanetakis Yep. Shoulder of giants and all that... I'm not very used to Bash, and I am trying to figure out why you declared these variables in this way: DC="${DC:-exec}" APP_NAME="${APP_NAME:-hello}" If I understand the docs correctly, the :- supplies a default value if the variable is not defined? When would this happen, as you are defining the variable in that same line?
@NickJanetakis
@NickJanetakis 3 жыл бұрын
@@JAUN320 Yeah that's defining a default value in case you decide not to supply that variable yourself when you call the script. If the value is undefined it falls back to the default, and since it's the same variable name for both it ensures DC and APP_NAME will always end up having some type of value.
@chadlowe6622
@chadlowe6622 3 жыл бұрын
@@NickJanetakis Gotcha, thx. (aka juan320)
@AlexeyDzuba
@AlexeyDzuba Жыл бұрын
It's amazing! Trying swith from make to your tool!
@paulkordes5687
@paulkordes5687 2 жыл бұрын
Also - have you figure out yet how to maybe auto display the help description alongside each command? Did this pretty trivially in Makefile
@NickJanetakis
@NickJanetakis 2 жыл бұрын
I didn't but it also hasn't come up where it was a compelling need. Basically it's not because it would be impossibly hard, I just haven't had to. I also think it gets more involved with the shell script because if you're talking about passing assorted arguments to commands, these 1 line help outputs become less useful unless you know what those args are, and the more space you take with adding them, the less space you have to fit things cleanly on 1 line. I've gone with using 1 or more line comments in each function as regular code commands and look them up as needed. So far so good.
@pwagner-beccard4691
@pwagner-beccard4691 Жыл бұрын
You implemented printing the description comments? Help so far just shows the commands, not the comments
@NickJanetakis
@NickJanetakis Жыл бұрын
For the run script only the commands are shown, not the comments. You could parse the file if you really wanted tho.
@btraadarsha
@btraadarsha 3 ай бұрын
Make works for windows too, does bash script work for windows?
@NickJanetakis
@NickJanetakis 3 ай бұрын
If you're using WSL (Windows Subsystem for Linux), yes. I recorded this video in Windows with WSL.
@btraadarsha
@btraadarsha 3 ай бұрын
@@NickJanetakis Thanks.
Taking Advantage of Using Snippets with UltiSnips and Vim-Snippets
18:15
Makefiles: 95% of what you need to know
1:01:53
Gabriel Parmer
Рет қаралды 119 М.
Harley Quinn lost the Joker forever!!!#Harley Quinn #joker
00:19
Harley Quinn with the Joker
Рет қаралды 27 МЛН
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 14 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 184 МЛН
Using envsubst to Merge Environment Variables into Config Files
8:37
you need to learn BASH Scripting RIGHT NOW!! // EP 1
12:14
NetworkChuck
Рет қаралды 992 М.
Using tmux Sessions, Windows, Panes and Vim Buffers Together
10:59
Nick Janetakis
Рет қаралды 42 М.
Creating Laser Focused Git Commits Using Git Add Patch
6:22
Nick Janetakis
Рет қаралды 7 М.
A Linux Dev Environment on Windows with WSL 2, Docker Desktop and More
34:23
Organize Your Text Based Notes from the Command Line with This Script
19:55
Reclaim Tons of Disk Space by Compacting Your Docker Desktop WSL 2 VM
6:43
Using Vim's Built in Complete Menu for Autocompleting Words
13:01
Nick Janetakis
Рет қаралды 72 М.
Scammed selling my MacBook, almost
15:09
Alex Ziskind
Рет қаралды 6 М.
Harley Quinn lost the Joker forever!!!#Harley Quinn #joker
00:19
Harley Quinn with the Joker
Рет қаралды 27 МЛН