webext-store-incompat-fixer
Version:
Package which clones a packed webextension and fixes incompatibilities with certain extension stores
50 lines (41 loc) • 1.3 kB
JavaScript
/* eslint-disable no-console */
import generate from './index.js';
const argList = process.argv.join('=').split('=');
let inputPath = null;
let edgeLocaleInclusions = null;
let manifestPolyfill = false;
let backgroundStrategy = null;
let whaleMessageLimit = false;
const stores = [];
argList.forEach((item, index) => {
if (item === '--input' || item === '-i') {
inputPath = argList[index + 1];
} else if (item === '--stores' || item === '--store' || item === '-s') {
stores.push(...argList[index + 1].toLowerCase().split(/[^a-z]/));
} else if (item === '--edge-locale-inclusions') {
edgeLocaleInclusions = argList[index + 1].split(',');
} else if (item === '--whale-message-limit') {
whaleMessageLimit = Number(argList[index + 1]);
} else if (item === '--manifest-polyfill') {
manifestPolyfill = true;
} else if (item === '--background-strategy') {
backgroundStrategy = argList[index + 1];
}
});
function logChangesOnSuccess ({ messageLog }) {
messageLog.forEach((message) => {
console.log(message);
});
}
function logErrors (...errors) {
console.error(...errors);
}
generate({
inputPath,
stores,
edgeLocaleInclusions,
whaleMessageLimit,
manifestPolyfill,
backgroundStrategy,
}).then(logChangesOnSuccess, logErrors);