Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run script after generate template using hygen?

I'm using hygen to create templates for my project.

How to run a script (nodejs) after hygen command complete in hygen way?

hygen my-package new awsome-package

For example after this command I want to add line to tsconfig.json in the current project.

like image 489
Jon Sud Avatar asked Oct 21 '25 12:10

Jon Sud


1 Answers

In hygen you have Shell option

This is mean that you can run a shell command (script), you just create a file and insert the following content for example:

 ---
 sh: "mkdir -p <%= cwd %>/given/app/shell && cat > <%= cwd %>/given/app/shell/hello.piped"
 ---
 hello, this was piped!

When you run your command then hello.piped will have hello, this was piped! text just by cmd command.

In this example, you can add a package to package.json and then run yarn install.

---
inject: true
to: package.json
after: dependencies
skip_if: lodash
sh: cd <%= cwd %> && yarn install
---
"lodash":"*",
like image 105
Shlomi Levi Avatar answered Oct 23 '25 01:10

Shlomi Levi