code: function ensureAndJoinPath(baseFolder, ...pathSegments) {
      let joinedPath = baseFolder;
      try {
          for (let pathSegment of pathSegments) {
              pathSegment = pathSegment.replace(/[\\\/]/g, '+');
              joinedPath = path.join(joinedPath, pathSegment);
              if (!fs.existsSync(joinedPath)) {
                  fs.mkdirSync(joinedPath);
              }
          }
      }
      catch (e) {
          throw new Error(`Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}`);
      }
      return joinedPath;
  }
docs: Create missing directories under the specified base directory, and return the resolved directory.
  
  Does not support "." or ".." path segments.
  Assumes the baseFolder exists.