function _ensureAndJoinPath()

in common/scripts/install-run.js [189:204]


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;
}