参考来自binding.gyp(node-gyp)的环境变量 [英] Referring to environment variables from binding.gyp (node-gyp)
问题描述
我正在使用node-gyp,我想使用我的 binding.gyp
文件中的环境变量值。
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?
推荐答案
据我所知,使用gyp(Google的父项目,而不是节点 https://code.google.com/p/gyp/ )。您可以以与shell中相同的方式访问环境变量。
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.
例如:
'$(FOO)'
将返回存储在 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)'
您可以找到Google的 gyp输入格式参考在线。
You can find Google's gyp input format reference online here.
这篇关于参考来自binding.gyp(node-gyp)的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!