MCPcopy Index your code
hub / github.com/darkreader/darkreader / getParams

Function getParams

tasks/build.js:100–157  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

98}
99
100function getParams(args) {
101 const argMap = {
102 '--api': PLATFORM.API,
103 '--chrome': PLATFORM.CHROMIUM_MV2,
104 '--chrome-mv2': PLATFORM.CHROMIUM_MV2,
105 '--chrome-mv3': PLATFORM.CHROMIUM_MV3,
106 '--chrome-plus': PLATFORM.CHROMIUM_MV2_PLUS,
107 '--firefox': PLATFORM.FIREFOX_MV2,
108 '--firefox-mv2': PLATFORM.FIREFOX_MV2,
109 '--firefox-mv3': PLATFORM.FIREFOX_MV3,
110 '--thunderbird': PLATFORM.THUNDERBIRD,
111 };
112 const platforms = {
113 [PLATFORM.CHROMIUM_MV2]: false,
114 [PLATFORM.CHROMIUM_MV2_PLUS]: false,
115 [PLATFORM.CHROMIUM_MV3]: false,
116 [PLATFORM.FIREFOX_MV2]: false,
117 [PLATFORM.THUNDERBIRD]: false,
118 };
119 let allPlatforms = true;
120 for (const arg of args) {
121 if (argMap[arg]) {
122 platforms[argMap[arg]] = true;
123 allPlatforms = false;
124 }
125 }
126 if ((args.includes('--chrome') || args.includes('--chrome-mv2')) && args.includes('--plus')) {
127 platforms[PLATFORM.CHROMIUM_MV2] = false;
128 platforms[PLATFORM.CHROMIUM_MV2_PLUS] = true;
129 }
130 if (allPlatforms) {
131 Object.keys(platforms).forEach((platform) => platforms[platform] = true);
132 }
133
134 // TODO(Anton): remove me
135 if (platforms[PLATFORM.FIREFOX_MV3]) {
136 platforms[PLATFORM.FIREFOX_MV3] = false;
137 console.log('Firefox MV3 build is not supported yet');
138 }
139
140 if (!pathExistsSync('./src/plus/')) {
141 platforms[PLATFORM.CHROMIUM_MV2_PLUS] = false;
142 }
143
144 const versionArg = args.find((a) => a.startsWith('--version='));
145 const version = versionArg ? versionArg.substring('--version='.length) : null;
146
147 const release = args.includes('--release');
148 const debug = args.includes('--debug');
149 const watch = args.includes('--watch');
150 const logInfo = watch && args.includes('--log-info');
151 const logWarn = watch && args.includes('--log-warn');
152 const logAssert = watch && args.includes('--log-assert');
153 const log = logWarn ? 'warn' : (logInfo ? 'info' : (logAssert ? 'assert' : null));
154 const test = args.includes('--test');
155
156 return {release, debug, platforms, watch, log, test, version};
157}

Callers 1

build.jsFile · 0.85

Calls 1

pathExistsSyncFunction · 0.90

Tested by

no test coverage detected