Github user matrosov-nikita commented on a diff in the pull request:

    https://github.com/apache/cordova-windows/pull/237#discussion_r127481484
  
    --- Diff: template/cordova/lib/MSBuildTools.js ---
    @@ -171,6 +182,54 @@ function getAvailableUAPVersions() {
         });
     
         return result;
    +};
    +
    +/**
    + * Lists all VS 2017+ instances dirs in ProgramData
    + * 
    + * @return {String[]} List of paths to all VS2017+ instances
    + */
    +function getWillowProgDataPaths() {
    +    if (!process.env.systemdrive) {
    +        // running on linux/osx?
    +        return [];
    +    }
    +    var instancesRoot = path.join(process.env.systemdrive, 
'ProgramData/Microsoft/VisualStudio/Packages/_Instances');
    +    if (!shell.test('-d', instancesRoot)) {
    +        // can't seem to find VS instances dir, return empty result
    +        return [];
    +    }
    +
    +    return fs.readdirSync(instancesRoot).map(function(file) {
    +        var instanceDir = path.join(instancesRoot, file);
    +        if (shell.test('-d', instanceDir)) {
    +            return instanceDir;
    +        }
    +    });
     }
     
    -module.exports.getAvailableUAPVersions = getAvailableUAPVersions;
    +/**
    + * Lists all installed VS 2017+ versions
    + * 
    + * @return {Object[]} List of all VS 2017+ versions
    + */
    +module.exports.getWillowInstallations = function () {
    +    var progDataPaths = getWillowProgDataPaths();
    +    var installations = [];
    +    progDataPaths.filter(function (progDataPath) {
    +        // make sure state.json exists
    +        return shell.test('-e', path.join(progDataPath, 'state.json'));
    --- End diff --
    
    `fs.existsSync`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to