Setup CI tests (#100)
* use @xarc/xrun to streamline tasks in an imperative manner * add lint-staged/husky for git hook tasks * run prettier across all files * fixing tests * add ci test workflow * add a ci workflow * remove precommit in favor of husky * add .prettierrc.js * reformat with prettier
This commit is contained in:
@@ -9,42 +9,41 @@ var config = require('../config');
|
||||
* @param color
|
||||
*/
|
||||
function changeExtensionIcon(color) {
|
||||
color = color ? color : '';
|
||||
|
||||
color = color ? color : '';
|
||||
var path = null;
|
||||
|
||||
var path = null;
|
||||
if (color !== '') {
|
||||
color = '-' + color;
|
||||
|
||||
if (color !== '') {
|
||||
color = '-' + color;
|
||||
path = './graphics/wakatime-logo-38' + color + '.png';
|
||||
|
||||
path = './graphics/wakatime-logo-38' + color + '.png';
|
||||
browser.browserAction.setIcon({
|
||||
path: path,
|
||||
});
|
||||
}
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
if (color === '') {
|
||||
browser.storage.sync
|
||||
.get({
|
||||
theme: config.theme,
|
||||
})
|
||||
.then(function (items) {
|
||||
if (items.theme == config.theme) {
|
||||
path = './graphics/wakatime-logo-38.png';
|
||||
|
||||
if (color === '') {
|
||||
browser.storage.sync.get({
|
||||
theme: config.theme
|
||||
}).then(function (items) {
|
||||
if (items.theme == config.theme) {
|
||||
path = './graphics/wakatime-logo-38.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
else {
|
||||
path = './graphics/wakatime-logo-38-white.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
browser.browserAction.setIcon({
|
||||
path: path,
|
||||
});
|
||||
} else {
|
||||
path = './graphics/wakatime-logo-38-white.png';
|
||||
|
||||
browser.browserAction.setIcon({
|
||||
path: path,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = changeExtensionIcon;
|
||||
|
||||
@@ -11,32 +11,32 @@ var in_array = require('./in_array');
|
||||
* @param state
|
||||
*/
|
||||
function changeExtensionState(state) {
|
||||
if (! in_array(state, config.states)) {
|
||||
throw new Error('Not a valid state!');
|
||||
}
|
||||
if (!in_array(state, config.states)) {
|
||||
throw new Error('Not a valid state!');
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 'allGood':
|
||||
changeExtensionIcon(config.colors.allGood);
|
||||
changeExtensionTooltip(config.tooltips.allGood);
|
||||
break;
|
||||
case 'notLogging':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.notLogging);
|
||||
break;
|
||||
case 'notSignedIn':
|
||||
changeExtensionIcon(config.colors.notSignedIn);
|
||||
changeExtensionTooltip(config.tooltips.notSignedIn);
|
||||
break;
|
||||
case 'blacklisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.blacklisted);
|
||||
break;
|
||||
case 'whitelisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.whitelisted);
|
||||
break;
|
||||
}
|
||||
switch (state) {
|
||||
case 'allGood':
|
||||
changeExtensionIcon(config.colors.allGood);
|
||||
changeExtensionTooltip(config.tooltips.allGood);
|
||||
break;
|
||||
case 'notLogging':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.notLogging);
|
||||
break;
|
||||
case 'notSignedIn':
|
||||
changeExtensionIcon(config.colors.notSignedIn);
|
||||
changeExtensionTooltip(config.tooltips.notSignedIn);
|
||||
break;
|
||||
case 'blacklisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.blacklisted);
|
||||
break;
|
||||
case 'whitelisted':
|
||||
changeExtensionIcon(config.colors.notLogging);
|
||||
changeExtensionTooltip(config.tooltips.whitelisted);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = changeExtensionState;
|
||||
module.exports = changeExtensionState;
|
||||
|
||||
@@ -8,15 +8,13 @@ var config = require('../config');
|
||||
* @param text
|
||||
*/
|
||||
function changeExtensionTooltip(text) {
|
||||
if (text === '') {
|
||||
text = config.name;
|
||||
} else {
|
||||
text = config.name + ' - ' + text;
|
||||
}
|
||||
|
||||
if (text === '') {
|
||||
text = config.name;
|
||||
}
|
||||
else {
|
||||
text = config.name + ' - ' + text;
|
||||
}
|
||||
|
||||
browser.browserAction.setTitle({title: text});
|
||||
browser.browserAction.setTitle({ title: text });
|
||||
}
|
||||
|
||||
module.exports = changeExtensionTooltip;
|
||||
module.exports = changeExtensionTooltip;
|
||||
|
||||
@@ -7,25 +7,24 @@
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function contains(url, list) {
|
||||
var lines = list.split('\n');
|
||||
var lines = list.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i ++) {
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
// Trim all lines from the list one by one
|
||||
var cleanLine = lines[i].trim();
|
||||
|
||||
// Trim all lines from the list one by one
|
||||
var cleanLine = lines[i].trim();
|
||||
// If by any chance one line in the list is empty, ignore it
|
||||
if (cleanLine === '') continue;
|
||||
|
||||
// If by any chance one line in the list is empty, ignore it
|
||||
if(cleanLine === '') continue;
|
||||
var lineRe = new RegExp(cleanLine.replace('.', '.').replace('*', '.*'));
|
||||
|
||||
var lineRe = new RegExp(cleanLine.replace('.', '\.').replace('*', '.*'));
|
||||
|
||||
// If url matches the current line return true
|
||||
if (lineRe.test(url)) {
|
||||
return true;
|
||||
}
|
||||
// If url matches the current line return true
|
||||
if (lineRe.test(url)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = contains;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
* @returns {string}
|
||||
*/
|
||||
function getDomainFromUrl(url) {
|
||||
var parts = url.split('/');
|
||||
var parts = url.split('/');
|
||||
|
||||
return parts[0] + "//" + parts[2];
|
||||
return parts[0] + '//' + parts[2];
|
||||
}
|
||||
|
||||
module.exports = getDomainFromUrl;
|
||||
module.exports = getDomainFromUrl;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function in_array(needle, haystack) {
|
||||
for (var i = 0; i < haystack.length; i ++) {
|
||||
if (needle == haystack[i]) {
|
||||
return true;
|
||||
}
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
if (needle == haystack[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = in_array;
|
||||
module.exports = in_array;
|
||||
|
||||
Reference in New Issue
Block a user