(devBundleDir, env)
| 122 | var cachedMSVSVersion; |
| 123 | |
| 124 | function addWindowsVariables(devBundleDir, env) { |
| 125 | // On Windows we provide a reliable version of python.exe for use by |
| 126 | // node-gyp (the tool that rebuilds binary node modules). #WinPy |
| 127 | env.PYTHON = env.PYTHON || path.join( |
| 128 | devBundleDir, "python", "python.exe"); |
| 129 | |
| 130 | // While the original process.env object allows for case insensitive |
| 131 | // access on Windows, Object.create interferes with that behavior, |
| 132 | // so here we ensure env.PATH === env.Path on Windows. |
| 133 | env.Path = env.PATH; |
| 134 | |
| 135 | if (cachedMSVSVersion) { |
| 136 | env.GYP_MSVS_VERSION = cachedMSVSVersion; |
| 137 | } |
| 138 | |
| 139 | if (env.GYP_MSVS_VERSION) { |
| 140 | return Promise.resolve(env); |
| 141 | } |
| 142 | |
| 143 | // If $GYP_MSVS_VERSION was not provided, use the gyp Python library to |
| 144 | // infer it, or default to 2015 if that doesn't work. |
| 145 | return new Promise(function (resolve) { |
| 146 | var nodeGypPylibDir = path.join( |
| 147 | devBundleDir, "lib", "node_modules", "node-gyp", "gyp", "pylib" |
| 148 | ); |
| 149 | |
| 150 | var child = require("child_process").spawn(env.PYTHON, ["-c", [ |
| 151 | "from gyp.MSVSVersion import SelectVisualStudioVersion", |
| 152 | "try:", |
| 153 | " print SelectVisualStudioVersion(allow_fallback=False).short_name", |
| 154 | "except:", |
| 155 | " print 2015" |
| 156 | ].join("\n")], { |
| 157 | cwd: nodeGypPylibDir, |
| 158 | stdio: "pipe" |
| 159 | }); |
| 160 | |
| 161 | var chunks = []; |
| 162 | child.stdout.on("data", function (chunk) { |
| 163 | chunks.push(chunk); |
| 164 | }); |
| 165 | |
| 166 | function finish(codeOrError) { |
| 167 | if (codeOrError) { |
| 168 | // In the event of any kind of error, default to 2015. |
| 169 | cachedMSVSVersion = "2015"; |
| 170 | } else { |
| 171 | cachedMSVSVersion = Buffer.concat(chunks) |
| 172 | .toString("utf8").replace(/^\s+|\s+$/g, ""); |
| 173 | } |
| 174 | |
| 175 | env.GYP_MSVS_VERSION = cachedMSVSVersion; |
| 176 | |
| 177 | resolve(env); |
| 178 | } |
| 179 | |
| 180 | child.on("error", finish); |
| 181 | child.on("exit", finish); |
no test coverage detected
searching dependent graphs…