function generateBazelWorkspaces(pkgs) {
        const workspaces = {};
        for (const pkg of pkgs) {
            if (!pkg.bazelWorkspaces) {
                continue;
            }
            for (const workspace of Object.keys(pkg.bazelWorkspaces)) {
                // A bazel workspace can only be setup by one npm package
                if (workspaces[workspace]) {
                    console.error(`Could not setup Bazel workspace ${workspace} requested by npm ` +
                        `package ${pkg._dir}@${pkg.version}. Already setup by ${workspaces[workspace]}`);
                    process.exit(1);
                }
                generateBazelWorkspace(pkg, workspace);
                // Keep track of which npm package setup this bazel workspace for later use
                workspaces[workspace] = `${pkg._dir}@${pkg.version}`;
            }
        }
        // Finally generate install_bazel_dependencies.bzl
        generateInstallBazelDependencies(Object.keys(workspaces));
    }
/**
     * Generate install_<workspace_name>.bzl files with function to install each workspace.
     */
Generate install_.bzl files with function to install each workspace.
Generate install_ . bzl files with function to install each workspace .
function generateBazelWorkspaces(pkgs) {
        const workspaces = {};
        for (const pkg of pkgs) {
            if (!pkg.bazelWorkspaces) {
                continue;
            }
            for (const workspace of Object.keys(pkg.bazelWorkspaces)) {
                if (workspaces[workspace]) {
                    console.error(`Could not setup Bazel workspace ${workspace} requested by npm ` +
                        `package ${pkg._dir}@${pkg.version}. Already setup by ${workspaces[workspace]}`);
                    process.exit(1);
                }
                generateBazelWorkspace(pkg, workspace);
                workspaces[workspace] = `${pkg._dir}@${pkg.version}`;
            }
        }
        generateInstallBazelDependencies(Object.keys(workspaces));
    }
function generateBazelWorkspaces ( pkgs ) { const workspaces = { } ; for ( const pkg of pkgs ) { if ( ! pkg . bazelWorkspaces ) { continue ; } for ( const workspace of Object . keys ( pkg . bazelWorkspaces ) ) { if ( workspaces [ workspace ] ) { console . error ( ` ${ workspace } ` + ` ${ pkg . _dir } ${ pkg . version } ${ workspaces [ workspace ] } ` ) ; process . exit ( 1 ) ; } generateBazelWorkspace ( pkg , workspace ) ; workspaces [ workspace ] = ` ${ pkg . _dir } ${ pkg . version } ` ; } } generateInstallBazelDependencies ( Object . keys ( workspaces ) ) ; }
Generate install_<workspace_name>.bzl files with function to install each workspace.
Generate install_<workspace_name > . bzl files with function to install each workspace .
// A bazel workspace can only be setup by one npm package // Keep track of which npm package setup this bazel workspace for later use // Finally generate install_bazel_dependencies.bzl