Closed mrch4n closed 1 year ago
Yes, I agree it is a bit weird 😅 But in our situation(we are calling two js scripts in one npm cmd), I can only found this solution which works on both *nix and windows machine ...
OK so now I understand the context: we have 2 actions template-builder
and data-builder
that we want to combine in one single script, data-builder
having to run after template-builder
.
The problem is that we need to pass one argument from the command line but this argument is lost when we combine scripts doing node action1 && node action2
.
The current solution on master
is... hacky! (I have never seen that JSON.parse(process.env.npm_config_argv, null, 2).remain[0];
).
Since we want to run data-builder
after the template-builder
, why not using NPM post
scripts?
{
"template-build": "node tools/template-builder",
"posttemplate-build": "npm run data-build",
}
A more robust solution would be to split commands and actions, having a file that exports
a buildData()
function we could call from several places, for example, but the post
script solution may be enough for now?
Hey Michael!
Thanks for your comment. Yes this is the perfect solution, I don't know we can use pre
and post
keywords 😄 I learnt something new, thanks you!
I updated my commit, please check 🙂
close https://github.com/UXPin/uxpin-issues/issues/1239
The
npm run template-build
cmd is broken. Root cause is npm removednpm_config_*
env var since V6 (https://github.com/npm/rfcs/blob/main/implemented/0021-reduce-lifecycle-script-environment.md)