Skip to content

Commit

Permalink
Merge pull request #95 from XhmikosR/rm-lodash
Browse files Browse the repository at this point in the history
Replace lodash with native methods
  • Loading branch information
tancredi authored Feb 7, 2021
2 parents 49b2eb1 + 0ab3966 commit 9960550
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"commander": "^7.0.0",
"glob": "^7.1.6",
"handlebars": "^4.7.6",
"lodash": "^4.17.20",
"slugify": "^1.4.6",
"svg2ttf": "^5.0.0",
"svgicons2svgfont": "^9.1.1",
Expand All @@ -53,7 +52,6 @@
"devDependencies": {
"@types/cli-color": "^2.0.0",
"@types/glob": "^7.1.3",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.25",
"@types/svg2ttf": "^5.0.0",
"@types/svgicons2svgfont": "^9.1.0",
Expand Down
11 changes: 5 additions & 6 deletions src/__mocks__/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import startsWith from 'lodash/startsWith';
const _path = jest.requireActual('path');
const _relative = _path.relative;

Expand All @@ -11,14 +10,14 @@ const resolve = (...paths: string[]) => {
path = !path ? normalise(cur) : _path.join(path, normalise(cur));
}

if (startsWith(path, projectDir)) {
if (path.startsWith(projectDir)) {
path = _path.join('/root/project', path.substr(projectDir.length));
} else if (startsWith(path, '/') && !startsWith(path, '/root')) {
} else if (path.startsWith('/') && !path.startsWith('/root')) {
path = _path.join('/root/', path.substr(1));
} else {
if (startsWith(path, './')) {
if (path.startsWith('./')) {
path = _path.join('/root/project/', path.substr(2));
} else if (!startsWith(path, '/')) {
} else if (!path.startsWith('/')) {
path = _path.join('/root/project/', path);
}
}
Expand Down Expand Up @@ -52,6 +51,6 @@ const join = (...segments: string[]): string => {

const normalise = (path: string) => path.replace(/\\/g, '/');

const isAbsolute = (path: string) => startsWith(path, '/root');
const isAbsolute = (path: string) => path.startsWith('/root');

module.exports = { resolve, relative, join, isAbsolute };
7 changes: 4 additions & 3 deletions src/core/config-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { RunnerOptions } from '../types/runner';
import { DEFAULT_OPTIONS } from '../constants';
import uniq from 'lodash/uniq';
import {
parseDir,
parseString,
Expand Down Expand Up @@ -37,9 +36,11 @@ const CONFIG_VALIDATORS: {
export const parseConfig = async (input: object = {}) => {
const options = { ...DEFAULT_OPTIONS, ...input };
const out = {};
const allKeys = [...Object.keys(options), ...Object.keys(CONFIG_VALIDATORS)];
const allkeys = [
...new Set([...Object.keys(options), ...Object.keys(CONFIG_VALIDATORS)])
];

for (const key of uniq(allKeys)) {
for (const key of allkeys) {
const validators = CONFIG_VALIDATORS[key];

if (!validators) {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"outDir": "lib",
"rootDir": "src",
"sourceMap": true,
"target": "ES6",
"types": ["node", "jest"]
},
"typeRoots": ["node_modules/@types"],
Expand Down

0 comments on commit 9960550

Please # to comment.