diff --git a/lintingDir/elm-files.js b/lintingDir/elm-files.js index 2c5b19d1..0ea13915 100644 --- a/lintingDir/elm-files.js +++ b/lintingDir/elm-files.js @@ -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') diff --git a/lintingDir/package-lock.json b/lintingDir/package-lock.json index 70cd7d24..7fcce089 100644 --- a/lintingDir/package-lock.json +++ b/lintingDir/package-lock.json @@ -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=" diff --git a/lintingDir/package.json b/lintingDir/package.json index 3c059e92..ccc477fa 100644 --- a/lintingDir/package.json +++ b/lintingDir/package.json @@ -11,7 +11,6 @@ "license": "ISC", "dependencies": { "fs-extra": "^3.0.1", - "glob": "^7.1.2", - "lodash": "^4.17.4" + "glob": "^7.1.2" } }