diff --git a/binding.gyp b/binding.gyp index 3a3a88187e0ad080f833d76251c728fa04f352a8..de10d9d900112eef0ec98f2d33356929d27f39ec 100644 --- a/binding.gyp +++ b/binding.gyp @@ -46,10 +46,11 @@ # io.js always reports versions >0 and always exports ALPN symbols. # Therefore, Node's major version will be truthy if and only if it # supports ALPN. The output of "node -v" is v[major].[minor].[patch], - # like "v4.1.1" in a recent version. We use grep to extract just the - # major version. "4", would be the output for the example. + # like "v4.1.1" in a recent version. We use cut to split by period and + # take the first field (resulting in "v[major]"), then use cut again + # to take all but the first character, removing the "v". 'defines': [ - 'TSI_OPENSSL_ALPN_SUPPORT=<!(node -v | grep -oP "(?<=v)(\d+)(?=\.\d+\.\d+)")' + 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)' ], 'include_dirs': [ '.', diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template index bfa6a56bf6bb1bc9399fb4aaba5519752d25794f..e86449fd3f9228ff44c1d7f0a6a58d62887ee974 100644 --- a/templates/binding.gyp.template +++ b/templates/binding.gyp.template @@ -48,10 +48,11 @@ # io.js always reports versions >0 and always exports ALPN symbols. # Therefore, Node's major version will be truthy if and only if it # supports ALPN. The output of "node -v" is v[major].[minor].[patch], - # like "v4.1.1" in a recent version. We use grep to extract just the - # major version. "4", would be the output for the example. + # like "v4.1.1" in a recent version. We use cut to split by period and + # take the first field (resulting in "v[major]"), then use cut again + # to take all but the first character, removing the "v". 'defines': [ - 'TSI_OPENSSL_ALPN_SUPPORT=<!(node -v | grep -oP "(?<=v)(\d+)(?=\.\d+\.\d+)")' + 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)' ], 'include_dirs': [ '.',