Skip to content

andrejlamov/project-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Given a project template folder with variables in paths and content

tree test-project
test-project
└── %NAME1%
    └── %NAME2%
        └── %NAME2%-hello.txt

2 directories, 1 file
cat test-project/%NAME1%/%NAME2%/%NAME2%-hello.txt
Test project

%NAME1%.%NAME2%

%GREET%

How are you?

Now run template.sh with variables set in the environment and a path to a template folder

mkdir -p hello
cd hello
NAME1=src NAME2=andrej/lamov GREET='hello world' ../template.sh ../test-project

It outputs some info…

Source template:
  /home/andrej/code/template/test-project
Target:
  /home/andrej/code/template/hello
Variables:
  GREET=hello world
  NAME1=src
  NAME2=andrej/lamov
Using sed:
   -e 's\%GREET%\hello world\g' -e 's\%NAME1%\src\g' -e 's\%NAME2%\andrej/lamov\g'
Copying:
  %NAME1%/%NAME2%/%NAME2%-hello.txt -> src/andrej/lamov/andrej/lamov-hello.txt

And it results in the following structure

tree hello
hello
└── src
    └── andrej
        └── lamov
            └── andrej
                └── lamov-hello.txt

4 directories, 1 file
cat hello/src/andrej/lamov/andrej/lamov-hello.txt
Test project

src.andrej/lamov

hello world

How are you?

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published