function resolveRoot(root, runfiles) {
        return __awaiter(this, void 0, void 0, function* () {
            // create a node_modules directory if no root
            // this will be the case if only first-party modules are installed
            if (!root) {
                if (!(yield exists('node_modules'))) {
                    log_verbose('no third-party packages; mkdir node_modules in ', process.cwd());
                    yield fs.promises.mkdir('node_modules');
                }
                return 'node_modules';
            }
            // If we got a runfilesManifest map, look through it for a resolution
            // This will happen if we are running a binary that had some npm packages
            // "statically linked" into its runfiles
            const fromManifest = runfiles.lookupDirectory(root);
            if (fromManifest)
                return fromManifest;
            // Account for Bazel --legacy_external_runfiles
            // which look like 'my_wksp/external/npm/node_modules'
            if (yield exists(path.join('external', root))) {
                log_verbose('found legacy_external_runfiles, switching root to', path.join('external', root));
                return path.join('external', root);
            }
            // The repository should be layed out in the parent directory
            // since bazel sets our working directory to the repository where the build is happening
            return path.join('..', root);
        });
    }
/**
     * Resolve a root directory string to the actual location on disk
     * where node_modules was installed
     * @param root a string like 'npm/node_modules'
     */
Resolve a root directory string to the actual location on disk
where node_modules was installed
@param root a string like 'npm/node_modules'
Resolve a root directory string to the actual location on disk where node_modules was installed @param root a string like ' npm / node_modules '
function resolveRoot(root, runfiles) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!root) {
                if (!(yield exists('node_modules'))) {
                    log_verbose('no third-party packages; mkdir node_modules in ', process.cwd());
                    yield fs.promises.mkdir('node_modules');
                }
                return 'node_modules';
            }
            const fromManifest = runfiles.lookupDirectory(root);
            if (fromManifest)
                return fromManifest;
            if (yield exists(path.join('external', root))) {
                log_verbose('found legacy_external_runfiles, switching root to', path.join('external', root));
                return path.join('external', root);
            }
            return path.join('..', root);
        });
    }
function resolveRoot ( root , runfiles ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { if ( ! root ) { if ( ! ( yield exists ( 'node_modules' ) ) ) { log_verbose ( 'no third-party packages; mkdir node_modules in ' , process . cwd ( ) ) ; yield fs . promises . mkdir ( 'node_modules' ) ; } return 'node_modules' ; } const fromManifest = runfiles . lookupDirectory ( root ) ; if ( fromManifest ) return fromManifest ; if ( yield exists ( path . join ( 'external' , root ) ) ) { log_verbose ( 'found legacy_external_runfiles, switching root to' , path . join ( 'external' , root ) ) ; return path . join ( 'external' , root ) ; } return path . join ( '..' , root ) ; } ) ; }
Resolve a root directory string to the actual location on disk
 where node_modules was installed
 @param root a string like 'npm/node_modules'
Resolve a root directory string to the actual location on disk where node_modules was installed @param root a string like ' npm / node_modules '
// create a node_modules directory if no root // this will be the case if only first-party modules are installed // If we got a runfilesManifest map, look through it for a resolution // This will happen if we are running a binary that had some npm packages // "statically linked" into its runfiles // Account for Bazel --legacy_external_runfiles // which look like 'my_wksp/external/npm/node_modules' // The repository should be layed out in the parent directory // since bazel sets our working directory to the repository where the build is happening