Referring to environment variables from binding.gyp (node-gyp)

帅比萌擦擦* 提交于 2019-12-10 16:46:24

问题


I am using node-gyp, and I would like to use the value of an environment variable inside my binding.gyp file.

Here is the hard way (list context):

'<!@(printf "%s" "$FOO")'

But is there an easier way?


回答1:


To the best of my knowledge from working with gyp (the parent Google's project, not the one that ships with node https://code.google.com/p/gyp/). You can access environment variables the same way you would have in the shell.

For example:

'$(FOO)'

Will return the data stored inside of FOO.

To get that information in a list context, I don't know if there is a better way than what you did, except for perhaps a more concise way:

'<!(echo $FOO)'

You can find Google's gyp input format reference online here.



来源:https://stackoverflow.com/questions/17023442/referring-to-environment-variables-from-binding-gyp-node-gyp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!