"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const check_package_1 = require("@pnpm/check-package");
const logger_1 = require("@pnpm/logger");
const dp = require("dependency-path");
const pFilter = require("p-filter");
const path = require("path");
const getContext_1 = require("../getContext");
const extendStoreStatusOptions_1 = require("./extendStoreStatusOptions");
async function default_1(maybeOpts) {
    const reporter = maybeOpts && maybeOpts.reporter;
    if (reporter) {
        logger_1.streamParser.on('data', reporter);
    }
    const opts = await extendStoreStatusOptions_1.default(maybeOpts);
    const ctx = await getContext_1.getContextForSingleImporter(opts);
    if (!ctx.wantedLockfile)
        return [];
    const pkgPaths = Object.keys(ctx.wantedLockfile.packages || {})
        .map((id) => {
        if (id === '/')
            return null;
        return dp.resolve(ctx.registries, id);
    })
        .filter((pkgId) => pkgId && !ctx.skipped.has(pkgId))
        .map((pkgPath) => path.join(ctx.storePath, pkgPath));
    const modified = await pFilter(pkgPaths, async (pkgPath) => !await check_package_1.default(path.join(pkgPath, 'package')));
    if (reporter) {
        logger_1.streamParser.removeListener('data', reporter);
    }
    return modified;
}
exports.default = default_1;
//# sourceMappingURL=index.js.map