mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-30 23:12:13 +03:00
Remove lodash dependency
This commit is contained in:
parent
f15c3d0374
commit
166699e294
@ -1,18 +1,21 @@
|
||||
const path = require('path');
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs-extra');
|
||||
const glob = require('glob');
|
||||
|
||||
const defaultGlob = '**/*.elm';
|
||||
const ignore = ['**/elm-stuff/**', '**/node_modules/**', 'lintingDir/**'];
|
||||
|
||||
function flatMap(array, fn) {
|
||||
return array.reduce((res, item) => res.concat(fn(item)), []);
|
||||
}
|
||||
|
||||
function getFiles(filename) {
|
||||
if (!fs.existsSync(filename)) {
|
||||
return [];
|
||||
}
|
||||
if (fs.lstatSync(filename).isDirectory()) {
|
||||
console.log(candidate);
|
||||
return _.flatMap(
|
||||
return flatMap(
|
||||
glob.sync('/' + defaultGlob, {
|
||||
root: filename,
|
||||
nocase: true,
|
||||
@ -28,9 +31,7 @@ function getFiles(filename) {
|
||||
// Recursively search directories for *.elm files, excluding elm-stuff/
|
||||
function resolveFilePath(filename) {
|
||||
// Exclude everything having anything to do with elm-stuff
|
||||
return getFiles(filename).filter(
|
||||
candidate => !candidate.split(path.sep).includes('elm-stuff')
|
||||
);
|
||||
return getFiles(filename).filter(candidate => !candidate.split(path.sep).includes('elm-stuff'));
|
||||
}
|
||||
|
||||
function globify(filename) {
|
||||
@ -52,17 +53,16 @@ function globifyWithRoot(root, filename) {
|
||||
|
||||
function getElmFilePaths(filePathArgs) {
|
||||
if (filePathArgs.length > 0) {
|
||||
return _.flatMap(filePathArgs, globify);
|
||||
return flatMap(filePathArgs, globify);
|
||||
}
|
||||
|
||||
const root = path.join(path.resolve(process.cwd()), '..');
|
||||
return globifyWithRoot(root, '**/*.elm');
|
||||
}
|
||||
|
||||
|
||||
function getElmFiles(filePathArgs) {
|
||||
const relativeElmFiles = getElmFilePaths(filePathArgs);
|
||||
return _.flatMap(relativeElmFiles, resolveFilePath).map(file => {
|
||||
return flatMap(relativeElmFiles, resolveFilePath).map(file => {
|
||||
return {
|
||||
filename: file,
|
||||
source: fs.readFileSync(file, 'utf8')
|
||||
|
5
lintingDir/package-lock.json
generated
5
lintingDir/package-lock.json
generated
@ -45,11 +45,6 @@
|
||||
"version": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.0.tgz",
|
||||
"integrity": "sha1-kufHRE5f/V+jLmqa6LhQNN+DR9A="
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.4",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
|
||||
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM="
|
||||
|
@ -11,7 +11,6 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fs-extra": "^3.0.1",
|
||||
"glob": "^7.1.2",
|
||||
"lodash": "^4.17.4"
|
||||
"glob": "^7.1.2"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user