aboutsummaryrefslogtreecommitdiff
path: root/node_modules/resolve-dependencies/lib/options.js
blob: 3e4711529814580e71ff75f9da6403149c160f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeOptions = void 0;
function normalizeOptions(args) {
    const options = {
        entries: [],
        cwd: process.cwd(),
        loadContent: true,
        expand: 'none',
        files: {},
        type: 'commonjs',
    };
    args.forEach((x) => {
        if (typeof x === 'string')
            return options.entries.push(x);
        if (x.cwd)
            options.cwd = x.cwd;
        if (Array.isArray(x.entries))
            options.entries.push(...x.entries);
        if ('expand' in x)
            options.expand = x.expand || 'none';
        if ('loadContent' in x)
            options.loadContent = Boolean(x.loadContent);
        if ('files' in x)
            Object.assign(options.files, x.files);
        if ('type' in x)
            options.type = x.type || 'commonjs';
    });
    options.entries = Array.from(new Set(options.entries));
    if (!options.entries.length) {
        try {
            options.entries.push(require.resolve(options.cwd));
        }
        catch (e) {
            throw new Error('No entry file found');
        }
    }
    return options;
}
exports.normalizeOptions = normalizeOptions;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQWFBLFNBQWdCLGdCQUFnQixDQUFDLElBQTJDO0lBQzFFLE1BQU0sT0FBTyxHQUFzQjtRQUNqQyxPQUFPLEVBQUUsRUFBYztRQUN2QixHQUFHLEVBQUUsT0FBTyxDQUFDLEdBQUcsRUFBRTtRQUNsQixXQUFXLEVBQUUsSUFBSTtRQUNqQixNQUFNLEVBQUUsTUFBbUI7UUFDM0IsS0FBSyxFQUFFLEVBQWE7UUFDcEIsSUFBSSxFQUFFLFVBQVU7S0FDakI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