Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/bump #442

Merged
merged 12 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# switch to `8` when https://github.com/actions/setup-node/issues/27 is fixed
node: [8.16.1, 10, 12]
node: [10.x, 12.x, 13.x]
os: [ubuntu-latest, windows-latest]

steps:
Expand All @@ -37,4 +36,4 @@ jobs:
uses: coverallsapp/github-action@master
if: startsWith(matrix.os, 'ubuntu') && matrix.node == 10
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
github-token: '${{ secrets.GITHUB_TOKEN }}'
32 changes: 17 additions & 15 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ const grouped = {
* @param {string} key Key to check
* @returns {boolean} True for alias
*/
const isAlias = key => {
const isAlias = (key) => {
if (isString(key) && key.length > 1) {
return false;
}

const aliases = Object.keys(meowOpts.flags)
.filter(k => meowOpts.flags[k].alias)
.map(k => meowOpts.flags[k].alias);
.filter((k) => meowOpts.flags[k].alias)
.map((k) => meowOpts.flags[k].alias);

return aliases.includes(key);
};
Expand All @@ -119,28 +119,30 @@ const isAlias = key => {
* @param {mixed} val Value to check
* @returns {boolean} Whether or not this is an empty object
*/
const isEmptyObj = val => isObject(val) && Object.keys(val).length === 0;
const isEmptyObj = (val) => isObject(val) && Object.keys(val).length === 0;

/**
* Check if value is transformed to {default: val}
* @param {mixed} val Value to check
* @returns {boolean} True if it's been converted to {default: value}
*/
const isGroupArgsDefault = val => isObject(val) && Object.keys(val).length === 1 && val.default;
const isGroupArgsDefault = (val) => isObject(val) && Object.keys(val).length === 1 && val.default;

/**
* Return regex if value is a string like this: '/.../g'
* @param {mixed} val Value to process
* @returns {mixed} Mapped values
*/
const mapRegExpStr = val => {
const mapRegExpStr = (val) => {
if (isString(val)) {
const match = val.match(/^\/(.*)\/([igmy]+)?$/);
return (match && new RegExp(escapeRegExp(match[1]), match[2])) || val;
const {groups} = val.match(/^\/(?<regex>[^/]+)(?:\/?(?<flags>[igmy]+))?\/$/) || {};
const {regex, flags} = groups || {};

return (groups && new RegExp(escapeRegExp(regex), flags)) || val;
}

if (Array.isArray(val)) {
return val.map(v => mapRegExpStr(v));
return val.map((v) => mapRegExpStr(v));
}

return val;
Expand All @@ -160,7 +162,7 @@ const normalizedFlags = reduce(
}

// Cleanup camelized group keys
if (groupKeys.find(k => key.includes(k)) && !validate(key, val)) {
if (groupKeys.find((k) => key.includes(k)) && !validate(key, val)) {
return res;
}

Expand All @@ -184,17 +186,17 @@ function run(data) {
const {_: inputs = [], css, ...opts} = {...normalizedFlags};

// Detect css globbing
const cssBegin = process.argv.findIndex(el => ['--css', '-c'].includes(el));
const cssBegin = process.argv.findIndex((el) => ['--css', '-c'].includes(el));
const cssEnd = process.argv.findIndex((el, index) => index > cssBegin && el.startsWith('-'));
const cssCheck = cssBegin >= 0 ? process.argv.slice(cssBegin, cssEnd > 0 ? cssEnd : undefined) : [];
const additionalCss = inputs.filter(file => cssCheck.includes(file));
const additionalCss = inputs.filter((file) => cssCheck.includes(file));
// Just take the first html input as we don't support multiple html sources for
const [input] = inputs.filter(file => !additionalCss.includes(file));
const [input] = inputs.filter((file) => !additionalCss.includes(file));

if (Array.isArray(css)) {
opts.css = [...css, ...additionalCss].filter(file => file);
opts.css = [...css, ...additionalCss].filter((file) => file);
} else if (css || additionalCss.length > 0) {
opts.css = [css, ...additionalCss].filter(file => file);
opts.css = [css, ...additionalCss].filter((file) => file);
}

if (data) {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function generate(params, cb) {
*/
function stream(params) {
// Return stream
return through2.obj(function(file, enc, cb) {
return through2.obj(function (file, enc, cb) {
if (file.isNull()) {
return cb(null, file);
}
Expand All @@ -82,7 +82,7 @@ function stream(params) {

cb(null, file);
})
.catch(error => cb(new PluginError('critical', error.message)));
.catch((error) => cb(new PluginError('critical', error.message)));
});
}

Expand Down
Loading